ruby / ruby/irb

`chws` w/o argument does not change current workspace to main

Open Beginner friendly
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

The document (doc/irb/irb.rd.ja) says chws or irb_change_workspace command with no arguments changes the current workspace to the home workspace (i.e. the main object assigned to self when IRB begins). This does not happen in some cases.

Using irb 1.1.0.pre.2 with MRI master (d806078237).

The following example illustrates the problem -- the second invocation of chws, without an argument, is expected to change the workspace back to main. Actually, the workspace is not changed.

irb(main):001:0> chws Object.new
=> #<Object:0x000055c15c4919e8>
irb(#<Object:0x000055c15c4919e8>):002:0> chws
=> #<Object:0x000055c15c4919e8>
irb(#<Object:0x000055c15c4919e8>):003:0>

The cause of the problem seems to be IRB::Context#change_workspace at lib/irb/ext/change-ws.rb#L32, which saves the @home_workspace (via #home_workspace) only when it is first called without arguments, while it should do so before changing the workspace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/irb/ext/change-ws.rb at IRB::Context#change_workspace and review how home_workspace is saved when chws is called with and without an argument. Reproduce the documented sequence with chws Object.new followed by chws. Done means the no-argument command returns to the original main workspace, as described in doc/irb/irb.rd.ja.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.