I am in Windows 7, I can see that all my gems are in :
C:\Users\alotfi2.gem\specs\api.rubygems.org%443\quick\Marshal.4.8
Last week we received an email from the admin that said :
After migration, your H: drive will be read-only. This means you'll be able to access and transfer your files but you won't be able to edit them or save any new files to your H: drive.
but when I tried to install a new gem I got :
gem install chronic
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - H:/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/chronic-0.10.2.gemspec
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.3.0
- RUBY VERSION: 2.4.2 (2017-09-14 patchlevel 198) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
- RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
- SPEC CACHE DIRECTORY: H:/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby24-x64/lib/ruby/gems/2.4.0
- H:/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\majid\cmder\bin
- C:\majid\cmder\vendor\git-for-windows\cmd
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu\Scripts
- C:\majid\cmder\vendor\conemu-maximus5
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu
- C:\Program Files (x86)\Shoes
- C:\Ruby24-x64\bin
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\Scripts\
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\
- C:\Users\alotfi2\AppData\Roaming\npm
- C:\Program Files\Docker Toolbox
- C:\majid\cmder\vendor\git-for-windows\usr\bin
- C:\majid\cmder\vendor\git-for-windows\usr\share\vim\vim74
- C:\majid\cmder\
your help is appreciated .
Thanks.
Your SPEC CACHE DIRECTORY still links to your H: drive, to change its value, you have to set environment variable GEM_SPEC_CACHE as stated in this thread.
To do so on Windows, you would want to use SetX command. For example:
SETX GEM_SPEC_CACHE C:\Users\User\.gem\abc
You should have writing access rights to directory C:\Users\User\.gem\abc for it to work.
Related
I have installed Twurl but for some reason I still can't use it. I believe I have it installed because it shows up when I type the ls command. Then I am able to navigate to the folder that Twurl is contained in. However, I am not able to go into the Twurl folder because it says it is not a directory. I am able to use the command open twurl, which opens up a seperate terminal window with a lot of information about Twurl, but I can't type anything. One other thing, when I try and run twurl authorize I get this response: twurl: command not found So my question is, how do I go about getting twurl to work now? Such that I can run the twurl authorize command.
gem env output:
- RUBYGEMS VERSION: 3.1.4
- RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/CharlieBagin/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/CharlieBagin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/CharlieBagin/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.2/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /Users/CharlieBagin/anaconda3/bin
- /Library/Frameworks/Python.framework/Versions/3.6/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
I think I might have installed it in two places. I originally used gem install twurl, but then it wasn't working and I was trying some things and used bundler to install at some point too.
When trying to install a gem i receive an error:
No such device or address # rb_file_s_stat - Z:/
when checking the gem environment variables i get the following return:
C:\Program Files (x86)\SOME_FOLDER\Ruby\bin>gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.6
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: Z:/.gem/ruby/2.3.0
- RUBY EXECUTABLE: "C:/Program Files (x86)/SOME_FOLDER/Ruby/bin/ruby.exe"
- EXECUTABLE DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/bin
- SPEC CACHE DIRECTORY: Z:/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\Program Files (x86)\Common Files\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Windows\System32\OpenSSH\
- C:\Program Files\TortoiseSVN\bin
- C:\Users\rekenmt\AppData\Local\Microsoft\WindowsApps
the problem is clear: USER INSTALLATION DIRECTORY and SPEC CACHE DIRECTORY are not valid paths (Z:/ disk does not exist.) the question therefore is:
how do i change those variables to point to another path
Thank you in advance
I had the same issue and running this in the command line fixed it for me.
SET HOME=%USERPROFILE%
Source here: https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#gem-commands-fails-if-home-maps-to-a-network-drive
I am trying to do a task periodically, and I have seen this. I have installed the gem 'timer' using bundle install
and then here is my Timer class:
require 'timers'
class Timer
def initialize
timers = Timers::Group.new
timers.every(5) { puts "Another 5 seconds" }
end
end
but when i run the class i face with the error:
`require': cannot load such file -- timers (LoadError)
and here is the output of my gem env :
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.3.0
- USER INSTALLATION DIRECTORY: /home/ubuntu/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.3.0/bin
- SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-2.3.0
- /usr/local/rvm/gems/ruby-2.3.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-rdoc --no-ri"
- "update" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/ubuntu/.nvm/versions/node/v4.4.3/bin
- /usr/local/rvm/gems/ruby-2.3.0/bin
- /usr/local/rvm/gems/ruby-2.3.0#global/bin
- /usr/local/rvm/rubies/ruby-2.3.0/bin
- /mnt/shared/bin
- /home/ubuntu/workspace/node_modules/.bin
- /home/ubuntu/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /mnt/shared/sbin
- /opt/gitl
- /opt/go/bin
- /mnt/shared/c9/app.nw/bin
- /usr/local/rvm/bin
This error tells us the code you are trying to load is not on the LOAD_PATH. When you require 'timers' you are telling Ruby to search the LOAD_PATH for a file called timers.rb and it cannot be located. Installing the gem does not put the gem on your load path.
It sounds like you are not using Bundler to manage your dependencies. Once you start depending on 3rd party code, you really should start using Bundler. It will put all the code you need on the LOAD_PATH and provide a ton of other helpful features.
If you are just messing around, one option you can do is:
ruby -I <path/to/timers/lib>
This will allow Ruby to locate timers.rb
I am trying to run a Ruby script to setup a token exchange with spotify. I know nothing about Ruby, so am at a loss at how to resolve the following error in response to the following command:
ruby ./spotify_token_swap.rb
/Users/jeff/.rvm/rubies/ruby-2.1.5-dev/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- encrypted_strings (LoadError)
from /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from ./spotify_token_swap.rb:6:in `<main>'
Line 54 of kernel_require.rb is:
return gem_original_require(path)
If it helps, here is my RubyGems environment:
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin14.0]
- INSTALLATION DIRECTORY: /Users/jeff/.rvm/gems/ruby-2.1.5-dev
- RUBY EXECUTABLE: /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jeff/.rvm/gems/ruby-2.1.5-dev/bin
- SPEC CACHE DIRECTORY: /Users/jeff/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev/bin
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev#global/bin
- /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/bin
- /Users/jeff/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/ImageMagick/bin
I am guessing that there is either a missing gem, or a problem with my path. But I really don't know. Can someone provide some handholding on how to resolve this problem?
Good debugging idea, but you went a bit too deep :) You don't need to know how Kernel.require works, just that
If the file named cannot be found, a LoadError will be raised.
You probably just need to install the encrypted_strings gem.
I installed rbenv and set up ruby and gems. Now if I run gem env then I got the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/myusername/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-13
- GEM PATHS:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /Users/myusername/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- /Users/myusername/Tools/.rbenv/libexec
- /Users/myusername/Tools/.rbenv/plugins/ruby-build/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/myusername/Tools/.rbenv/shims
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /Users/myusername/Tools/./bin
- /Users/myusername/Tools/.rbenv/bin
Well.. all looks good except for SPEC CACHE DIRECTORY and GEM PATHS, all others have self-configured paths. (So I really don't want any dev-related directories directly placed in my user home folder.) Is there a way to flexibly change these two env variables without affecting normal functioning of ruby, gem and rbenv etc.?
Thanks!
Actually I searched online and found the solution.
Just put the following in your .profile (Max OS) or .bashrc (Linux)
export GEM_PATH=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
export GEM_SPEC_CACHE=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/specs
Make sure the folder you put there existed. Then source the .profile or .bashrc, or simply restart your terminal. It is tested working now my env is correct.
Reference:
https://github.com/rubygems/rubygems/pull/489