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

How to bypass RubyGems prompts in CI - bundler's executable "bundle" conflicts with ... #5245

Closed
1 of 5 tasks
MSP-Greg opened this issue Dec 30, 2021 · 7 comments · Fixed by #2929
Closed
1 of 5 tasks
Labels

Comments

@MSP-Greg
Copy link
Contributor

Using WIndows Ruby 3.1 on Actions. When trying to perform:

gem install bundler -v "~> 2"

The following error is generated:

  ERROR:  Error installing bundler:
  	"bundle" from bundler conflicts with C:/hostedtoolcache/windows/Ruby/3.1.0/x64/bin/bundle

When running locally, RubyGems prompts with:

bundler's executable "bundle" conflicts with C:/rubies/Ruby31-x64/bin/bundle
Overwrite the executable? [yN]

What's the recommended way to bypass the prompt in CI?

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

I will abide by the code of conduct.

@MSP-Greg
Copy link
Contributor Author

JFYI, gem update --system overwrites the bin files with no prompt.

@eregon
Copy link
Contributor

eregon commented Jan 3, 2022

gem install bundler --force seems to be a workaround (from ruby/setup-ruby#253 (comment))

But that sounds like either RubyGems should just override, or that the bin/bundle file in the 3.1.0 release is not the same as the one RubyGems would generate.

I think in general RubyGems cannot assume bin/ files are exactly the same it would generate (cannot assume the third line is This file was generated by RubyGems).
For instance on Linux when compiling CRuby with --enable-load-relative the bin/* files are different, and this causes the same error: ruby/setup-ruby#98 (comment)

@MSP-Greg
Copy link
Contributor Author

MSP-Greg commented Jan 4, 2022

@deivid-rodriguez

Happy New Year! Don't know if you (or anyone else) have time for this issue, but please see ruby/setup-ruby#224 (comment).

Most of this is due to the setup-ruby action installing Bundler 2.3.4. Maybe the best thing to do is update RubyGems for Ruby 2.3 thru 2.5, and just update Bundler for Ruby 2.6 and later. I.think. We may have a fix for the issue with Windows Ruby 3.1.0, which was the original issue...

@MSP-Greg
Copy link
Contributor Author

MSP-Greg commented Jan 6, 2022

Windows - It depends on one's setup, but Windows users may often have two bash shells they can use, one from Git, and one from MSYS2. So, Windows Rubies have two bin files for stdlibs/gems that run from the command line, which includes gem and bundle. One file has a .cmd or .bat extension, the other (the bash one) has no extension.

Updating bundler creates a bash script with the shebang line coded to Ruby's actual path. The shipped bash script's shebang uses #!/usr/bin/env ruby, since the installation directory is chosen by the user.

At present I can't think of any way to fix the issue. Not sure whether to close...

@eregon
Copy link
Contributor

eregon commented Jan 6, 2022

@MSP-Greg Could you show the bin/bundler you have locally on Windows (either through RubyInstaller or mswin/mingw-loco)?
My theory is on Windows Ruby changes those files at build/install times and hence we get this error.
But I'd like to verify the file is indeed modified on Windows.

@MSP-Greg
Copy link
Contributor Author

MSP-Greg commented Jan 7, 2022

@eregon Thanks, I reviewed things again, and the issue isn't the above. The following prefixes the normal bash bin files:

:""||{ ""=> %q<-*- ruby -*-
@"%~dp0ruby" -x "%~f0" %*
@exit /b %ERRORLEVEL%
};{ #
bindir="${0%/*}" #
exec "$bindir/ruby" "-x" "$0" "$@" #
>,
}

I think it was added to allow the bash bin files and the Windows bin files to be the same. It's added in Ruby's tool/rbinstall.rb. I think that's where the change should occur? Lars and I can patch around it, but fixing the source is probably better. JFYI, I'm still locked out at https://bugs.ruby-lang.org/ due to the wonderful TFA...

@deivid-rodriguez
Copy link
Member

I didn't have time to have a look at this in detail but this reminded me of #2929, so I rebased it. Maybe it fixes things, can you try?

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

Successfully merging a pull request may close this issue.

3 participants