Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gem commands fail if Windows user have a white space when installed for all users #332

Closed
HatsuMora opened this issue Jan 19, 2023 · 0 comments

Comments

@HatsuMora
Copy link

I reported this issue first in rubygems/rubygems#6288 and they recommended me to also create a issue here.

What problems are you experiencing?

After upgrading from rubygems (gem) from 3.3.3 to 3.4.4 I could not install any gem or run several gem-related commands.
For example gem env.

ERROR: While executing gem ... (Gem::CommandLineError)
Unknown environment option [Rincón]

or gem install rails:
ERROR: While executing gem ... (URI::InvalidURIError)
URI must be ascii only "Rinc\u00F3n".

I tried to investigate the issue myself and find out that there is value.split(" ") on C:\langs\Ruby32-x64\lib\ruby\3.2.0\rubygems\command.rb:79 that will split arguments by white space therefore my user name is being splitter and miss interpreted. This extra arg is set by lib\ruby\3.2.0\rubygems\defaults\operating_system.rb:11. Operating system is setting a default --install-dir and --bindir based on Gem.user_dir.

As a workaround for myself, I added wrapped both paths on ' in operating_system.rb and change the split to @extra_args = value.split(/\s+(?=([^']*"[^']*')*[^']*$)/) in command.rb (split by white spaces that are not between single quotes).

Steps to reproduce

  1. Create a windows user that contains a white space on the user path.
  2. Install Ruby+Devkit 3.2.0-1 (x64) from Ruby Installer.
  3. When asked, install for all users. (Requires elevation)
  4. run gem env or gem install rails

What's the output from ridk version?

ruby:
path: C:/langs/Ruby32-x64
version: 3.2.0
platform: x64-mingw-ucrt
ruby_installer:
package_version: 3.2.0-1
git_commit: 5507d7c
msys2:
path: C:\langs\Ruby32-x64\msys64
cc: gcc (Rev7, Built by MSYS2 project) 12.2.0
sh: GNU bash, version 5.2.9(1)-release (x86_64-pc-msys)
os: Microsoft Windows [Version 10.0.22621.1105]

larskanis added a commit that referenced this issue Feb 9, 2023
1. Use Array for of rubygems options to allow directory with white space (fixes #322)
2. Don't overwrite GEM_HOME or BUNDLE_SYSTEM_BINDIR if already present
3. Don't set bindir to a non-existing directory
   This is related to rubygems/rubygems#6332

Fixes #332
larskanis added a commit that referenced this issue Feb 9, 2023
1. Use Array for of rubygems options to allow directory with white space (fixes #332)
2. Don't overwrite GEM_HOME or BUNDLE_SYSTEM_BINDIR if already present
3. Don't set bindir to a non-existing directory
   This is related to rubygems/rubygems#6332

Fixes #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant