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

Error "An error occurred while installing" does not have clean command #3321

Closed
fulldecent opened this issue Apr 12, 2019 · 9 comments · Fixed by #4778
Closed

Error "An error occurred while installing" does not have clean command #3321

fulldecent opened this issue Apr 12, 2019 · 9 comments · Fixed by #4778

Comments

@fulldecent
Copy link

I ran the command bundle install --path vendor/bundle and somewhere inside it had an error.

Then Bundler helpfully isolated the package that was failing:

An error occurred while installing http_parser.rb (0.6.0), and Bundler cannot continue.
Make sure that gem install http_parser.rb -v '0.6.0' --source 'https://rubygems.org/' succeeds before bundling.

However the copy-paste command gem install http_parser.rb -v '0.6.0' --source 'https://rubygems.org/' will install in a different way (requiring sudo) than Bundler was using (from --path vendor/bundle).

This error message could be improved if Bundler will output a more comparable command to what it was actually attempting to run.

@hsbt hsbt transferred this issue from rubygems/bundler Mar 14, 2020
@deivid-rodriguez
Copy link
Member

I think we should definitely improve this 👍. If BUNDLE_PATH is configured, we should add a proper --install-dir to the suggested command.

@vinicius0197
Copy link

vinicius0197 commented Dec 22, 2020

Hello @deivid-rodriguez , I'm looking forwards to start contributing to rubygems and would love to get started with this issue :)

@deivid-rodriguez
Copy link
Member

Hello @vinicius0197, please go ahead! 👍

@vinicius0197
Copy link

@deivid-rodriguez Took a long time to start working on this, but I've been digging on the codebase lately and found that those error messages are generated by the gem_install_message method here. I'm trying to run my local repository of RubyGems with bundle install --path vendor/bundle to find out how to access BUNDLE_PATH.

As the CONTRIBUTING documentation suggests, I'm using ruby -Ilib bin/gem install to run commands from the repo, but I'm still trying to figure out how to debug the code better. My first idea was to write a test case and start from there. I imagine the path_spec.rb file would be te right place to put this test, right? From there I could try to figure out how to find out if BUNDLE_PATH is configured and customize the error message.

@deivid-rodriguez
Copy link
Member

Hi @vinicius0197!

I was recently thinking that I'm not sure printing this command is helpful. Even if we fix this issue, it's a different command possibly run on a different context, so we will never be able to guarantee that the command will led to the same error. And even if it was correct, it's just going to print the same error than bundle install.

I think I would remove this recommendation altogether, as long as it's still clear which gem failed to install and the error that was raised.

Not sure what others think.

@vinicius0197
Copy link

vinicius0197 commented Jan 26, 2021

@deivid-rodriguez Hm, got it. So we would omit the Make sure that gem install .... succeeds before bundling. message from the bundler output altogether? I can send a small PR with that change.

@deivid-rodriguez
Copy link
Member

Yes, in my option we should omit that message from the output, and also print the backtrace unconditionally by removing the if Bundler.ui.debug? from

message += " " + e.backtrace.join("\n ") + "\n\n" if Bundler.ui.debug?
.

@simi How do you feel about that?

@vinicius0197
Copy link

@deivid-rodriguez All right. To conform with the contributing guideline, I'm trying to write some tests for my changes, but I'm still a bit confused about how tests work on the RubyGems repo. How would I go about running a single test file on bundler/spec ? Running rspec path/to/file just gives me lots of errors. Don't know if there's some Rake command that I should use instead?

@deivid-rodriguez
Copy link
Member

Hei @vinicius0197, right now you need to switch to the bundler folder to run bundler specs. We can probably improve this so that you don't need to swich folders and you can run rspec directly from the root of the repository like you tried. But for now, cd bundler, and then bin/rspec path/to/file.

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