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.
Related
I got this error message:
.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
I reinstalled Ruby
rvm reinstall ruby-2.5.1
it gives an error message:
Error running '__rvm_with ruby-2.5.1 gemset_pristine', please read
/home/zoli/.rvm/log/1533209563_ruby-2.5.1/gemset.pristine-ruby-2.5.1.log
This is how I first run into this error:
$ gem list bun
*** LOCAL GEMS ***
bundler (default: 1.16.2)
Gem list gives a list of gems - some includes (default: ...) part. What does it mean?
I ran into this Github thread: bundler https://github.com/bundler/bundler/issues/6290
which has the same issue:
(default: 1.16.1, default: 1.16.0)
It gives an error when I try to run commands with Ruby gems.
How to install Rubies with RVM without using any binary? What does this (default) part mean?
The default part lists the default gem versions, the ones that are part of a specific Ruby.
You can find a list of default gems per Ruby version at https://stdgems.org/. Quote from that same site:
There are two different kinds of standard gems:
Default gems: These gems are part of Ruby and you can always require them directly. You cannot remove them. They are maintained by Ruby
core.
Bundled gems: The behavior of bundled gems is similar to normal gems, but they get automatically installed when you install Ruby. They
can be uninstalled and they are maintained outside of Ruby core.
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 currently trying to upgrade an existing app from Rails 4.2.3 to Rails 5.
then I followed this tutorial : http://railsapps.github.io/updating-rails.html
It recommends having RVM as Ruby version manager as well as gemsets manager. I am under windows 10 and because I couldn't find an easy solution to get RVM I have URU instead.
Well, no big deal. I have installed URU as well as another Ruby version enabling Rails 5 (Ruby 2.2.6)
Though, as mentionned below in the tutorial I have also tried to install nokogiri through command prompt:
gem install nokogiri
It failed with the following :
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri
-1.6.8.1-x86-mingw32/lib/nokogiri/2.2/nokogiri.so
Well I wasn't really bothered and decided to go on.. Though now every bundle install fails too !! But I dont even have any reference to nokogiri in my gemfile. (It is though in my gemfile.lock but if I try to remove it, I get a corrupt gemfile.lock error)
a bundle show gives the following:
Gems included by the bundle:
Your bundle is locked to nokogiri (1.6.8.1-x86-mingw32), but that version could
not be found in any of the sources listed in your Gemfile. If you haven't
changed sources, that means the author of nokogiri (1.6.8.1-x86-mingw32) has
removed it. You'll need to update your bundle to a different version of nokogiri
(1.6.8.1-x86-mingw32) that hasn't been removed in order to install.
Any easy solution to this ?
Delete your path folder(if it shows) and your Gemfile.lock .
Then place this in your gem file
gem 'nokogiri', '~> 1.6', '>= 1.6.8.1'
After that run bundle install .Remove the nokogiri from your gemfile
I have selected a gemset with
rvm use ruby-2.1.2#deploy
in my gemfile I have:
gem 'transip', :git => 'git://github.com/rempargo/transip.git'
then I run bundle install and get the following output:
....
....
Installing wasabi 3.3.0
Installing savon 2.5.1
Using transip 0.4.2 from git://github.com/rempargo/transip.git (at master)
Using bundler 1.6.2
Your bundle is updated!
But when I do gem list all gems except the transip one are listed.
The other gems are not installed in gemset 'ruby-2.1.2' or 'ruby-2.1.2#global', but are really installed in the gemset ruby-2.1.2#deploy
I tried also to use bundle exec install although I never used the 'exec' before, but it does not work.
Is there a problem using bundler and rvm when using gems that uses a link to a repository?
I'm using:
Mac OS X 10.9.3 (With command-line tools installed)
rvm 1.25.26
bundler 1,6,2
P.S. This all happened after upgrading to Maverick, when some libraries where not working anymore, and I had to install ruby again with rvm.
gem list will show all the gems installed on your system
bundle show gem_namewill give you whether that gem is installed in your current application bundled gemset
I am working on ubuntu and rvm. In any case I tried to use sudo gem (any command) it does not recognize gem as command. In addition if I use gem seperately as:
gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: Possible alternatives: rails
I got that error. I cannot see the reason.
rvm version 1.10.3
ruby version 1.8.7
gem version 1.6.7
What is the possible reason behind this?
Re-install all rvm and ruby and the gems, solved my problem.