I have ruby project and I installed all gems using 'bundle install'. Gems was installed in ./vendor/bundle. But I use ruby installed by rvm in another directory and when I try to do something (some command) It is looking for gems in rvm directory. How to install all gems in rvm directory?
Edit:
I installed all gems but when I tried to user simple ruby -T I get:
/home/arkency/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:298:in `to_specs': Could not find 'rake' (>= 0) among 1 total gem(s) (Gem::LoadError)
from /home/arkency/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:309:in `to_spec'
from /home/arkency/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /home/arkency/.rvm/gems/ruby-1.9.3-p545/bin/rake:22:in `<main>'
from /home/arkency/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `eval'
from /home/arkency/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `<main>'
My gem list contain only:
gem list
*** LOCAL GEMS ***
bundler (1.6.2)
By default, bundler installs gems to the system gem store. However, it has an optional configuration setting to install gems into another directory (in your case vendor/bundle). These gems are then only available in the specific bundler context.
You can force bundler to install the gems into the system gem store by running
bundle install --system
thus making them available to your global ruby installation.
This is necessary as bundler remembers certain options (e.g. the path where to install gems to) in the .bundle directory besides your Gemfile.
Related
user#machine:~$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.4)
net-telnet (0.1.1)
power_assert (0.2.7)
psych (2.0.17)
rake (10.5.0)
rdoc (4.2.1)
sass (3.4.23)
test-unit (3.1.7)
user#machine:~$ sudo gem uninstall rake
ERROR: While executing gem ... (Gem::InstallError)
rake is not installed in GEM_HOME, try:
gem uninstall -i /usr/share/rubygems-integration/all rake
user#machine:~$ sudo gem uninstall -i /usr/share/rubygems-integration/all rake
Remove executables:
rake
in addition to the gem? [Yn] Y
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/share/rubygems-integration/all/bin directory.
user#machine:~$ ls /usr/share/rubygems-integration/all/
specifications
user#machine:~$
I can not uninstall this gem in particular, neither use it :(
If seems that it doesn't exist.
My ruby verison is 2.3.1.p112
Ideally you would use RVM or rbenv to create a local sandbox and handle your Ruby install and gems instead of the system default. Then you won't have to use sudo you can just use gem uninstall <gem>. It doesn't let you have access for a reason, so it's harder to accidentally mess up the system Ruby.
If you can just read these install directions to get set up with RVM and then install the gems you used previously in your new environment. It'll save you a lot headaches in the future managing Ruby and gems.
--
If you don't want to do that you could try this answer
Try this answer from this related question.
gem list -d 'name of gem' and note the "Installed at:" location
sudo gem uninstall 'name of gem' -i 'the path noted above'
If it still returns a permissions error. Create a folder /bin, in the path above. Continue uninstalling as in step 2, still using the original path (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8).
sudo is not a magic wand that casts a spell “do it anyway.”
When you list your gems, you execute plain gem list from the user. It lists gems installed for the user. Afterwards you try sudo gem uninstall rake. Why do you expect superuser’s list of gems being the same as user’s one?
To remove user’s gems, listed with gem list, use gem uninstall rake. Without sudo.
To list superuser’s gems, that you were tried to remove with sudo gem uninstall rake, use sudo gem list. With sudo.
More info on sudo: http://aplawrence.com/Basics/sudo.html
I am installing Dashing Dashboard on Pi3. I have "Could not find 'bundler' problem in installation steps. How can I finish the installation?
$ source /home/pi/.rvm/scripts/rvm
-> OK
$ rvm current
ruby-2.3.0
$ bundle
/usr/lib/ruby/2.1.0/rubygems/dependency.rb:298:in 'to_specs': Could not find 'bundler' (>= 0) among 42 total gem(s) (Gem::LoadError)
from /usr/lib/ruby/2.1.0/rubygems/dependency.rb:309:in 'to_specs'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in 'gem'
from /usr/local/bin/bundle:22:in '<main>'
$ gem install bundler
-> OK
$ bundle
-> the same problem
I imagine you've messed up your permissions, installing bundler into system gems by running sudo gem install bundler.
Delete the bundler and then install it under RVM. Double check your paths so its being installed in the RVM gem stash, not system's.
I'm trying to run different gems on Raspbian and they won't work. I tried on two gems: Jekyll and Lolcat.
I've installed both gems:
pi#moon ~ $ sudo gem install lolcat
Successfully installed lolcat-42.0.99
1 gem installed
Installing ri documentation for lolcat-42.0.99...
Installing RDoc documentation for lolcat-42.0.99...
pi#moon ~ $ sudo gem install jekyll
Successfully installed jekyll-1.4.3
1 gem installed
Installing ri documentation for jekyll-1.4.3...
Installing RDoc documentation for jekyll-1.4.3...
These are the errors I receive.
pi#moon ~ $ lolcat --help
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find lolcat (>= 0)
amongst [bundler-1.5.3, bundler-unload-1.0.2, executable-hooks-1.3.1, gem-wrappers-1.2.4, rubygems-bundler-1.4.2, rvm-1.11.3.9] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/lolcat:22:in `<main>'
pi#moon ~ $ jekyll
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find jekyll (>= 0)
amongst [bundler-1.5.3, bundler-unload-1.0.2, executable-hooks-1.3.1, gem-wrappers-1.2.4, rubygems-bundler-1.4.2, rvm-1.11.3.9] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/jekyll:22:in `<main>'
I was advised to re-install ruby using RVM. I did, and when I run rvm list to see my ruby versions, I get the following:
pi#moon ~ $ rvm list
rvm rubies
=> ruby-1.9.1-p431 [ armv6l ]
* ruby-2.1.0 [ armv6l ]
I tried running the gems on both versions (1.9.1 & 2.1.0) but receive the same errors.
Thank you in advance!
Several things were wrong here:
Firstly, the gems had been installed as root, which meant that their codebase (and any shell scripts or binary commands their installation generated) were root's, not the current users. This was the cause of OP's original failure - namely, the executable scripts could not resolve the gems since they were installed under a different user's rvm environment.
Secondly, even had the gems commands been accessible this could have created all sorts of security problems, given that the files belonged to root. Potentially, if these gems had contained badly-behaved code (or malicious code) embedded within them, a privilege escalation attack might have been possible against the system running the ruby process.
Basically, the TL;DR is that you should always install the gems using the credentials of the user who needs to run the ruby process that requires the gems, and this user should never be root or have superuser rights to the system or filesystem.
I want to play around with three similar Ruby gems called 'yahoofinance' 'yahoo-finance' and 'yahoo_stock'. I'm interested in how each gem works with Yahoo Finance. So I start with creating an rvm gemset,
[sandbox]$ rvm gemset create finance
'finance' gemset created (/Users/milktrader/.rvm/gems/ruby-1.9.2-p0#finance).
Then I use it,
[sandbox]$ rvm gemset use finance
Now using gemset 'finance'
Then I attached it to a ruby,
[sandbox]$ rvm 1.9.2-head#finance
Then I installed the three gems above,
[sandbox]$ gem install yahoo-finance yahoofinance yahoo_stock
Successfully installed yahoo-finance-0.0.2
Successfully installed yahoofinance-1.2.2
Successfully installed yahoo_stock-1.0.2
3 gems installed
.
.
.
Installing RDoc documentation for yahoo_stock-1.0.2...
Now I'm incorrectly assuming I can require all three gems in an irb sesssion. Only one of them returns true.
ruby-1.9.2-head > require 'yahoofinance'
=> true
While the other two throw errors.
ruby-1.9.2-head > require 'yahoo-finance'
LoadError: no such file to load -- yahoo-finance
ruby-1.9.2-head > require 'yahoo_stock'
SyntaxError: ...
Is there a problem with the gems or my installation?
NOTE: I am foggy about the rvm gemset use command, and it's probably not being used correctly above.
[sandbox]$ gem list
*** LOCAL GEMS ***
bundler (1.0.7)
rake (0.8.7)
yahoo-finance (0.0.2)
yahoo_stock (1.0.2)
yahoofinance (1.2.2)
I initially hit the same errors you did, so it's not environment.
The issue with yahoo-finance is that it must be required as yahoo_finance.
The issue with yahoo_stock is a syntax error, indicating that the file is being loaded, but not interpreted correctly. Upon inspecting the Github project's changelog, we see that this syntax error in history.rb for Ruby 1.9.1 was fixed in version 1.0.5, but the version in the central gem repository is 1.0.2. Turns out that the gem's owner now calls the gem nas-yahoo_stock, so running gem install nas-yahoo_stock should resolve that issue.
Can anyone help with an odd Ruby Gem problem I'm having - note I've installed many gems in the past and never seen this.
I've downloaded the net-ssh and net-sftp gems using the following commands:
sudo gem install net-ssh
sudo gem install net-sftp
both installed successfully. However when I reference the files within my code I get the following error:
./workers/ffmpeg_worker.rb:6:in `require': no such file to load -- net/ssh (LoadError)
from ./workers/ffmpeg_worker.rb:6
from ./workers/tests/test_ffmpeg_worker.rb:3:in `require'
from ./workers/tests/test_ffmpeg_worker.rb:3
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
Note when I do:
gem list --local
The gems are listed as such:
net-scp (1.0.2)
net-sftp (2.0.2, 1.1.0)
net-ssh (2.0.15, 1.1.2)
net-ssh-gateway (1.0.1)
Any clues?
When I see this sort of thing, it usually comes down to having more than one Ruby installed on the machine (which means more than one gem location, etc.), and different apps or environments getting confused about which one to load.
Check for that first. If that isn't the answer, do a gem which net/ssh to see where RubyGems thinks the gem is installed -- make sure it isn't the local user's .gems directory or something.
If neither one solves the mystery, stick some debugging code into your worker script and have it output its load path ($:) so you can see where it's looking.