So I'm switching to a project that is using ruby. They use asdf as a package manager
I’m having trouble installing the gems, I’m using zsh and I’m thinking there might be an issue with the paths
Running gem install bundler outputs: You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
ruby -v
outputs: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
which ruby
output: /usr/bin/ruby
And I tried setting a global version for ruby with asdf global ruby 2.5.3 but that doesn’t seem to change the version
This is my gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/carlos.grijalva/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/carlos.grijalva/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/carlos.grijalva/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/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:
- /Users/carlos.grijalva/.asdf/shims
- /Users/carlos.grijalva/.asdf/bin
- /Users/carlos.grijalva/bin
- /usr/local/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
It sounds like you may need to add the relevant lines to your .zshrc so asdf shims get recognized. You can find the instructions here
For macOS & zsh the correct lines to append to .zshrc are:
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
After doing so, either source ~/.zshrc or restart your terminal
Related
I am running macOS Catalina 10.15.3 and cannot execute Jekyll commands. I suspect it's the result of too many versions of Ruby / RubyGems installed and the conflicting paths I have created haphazardly, I'm pretty sure my path variable is completely messed up:
echo $PATH returns
/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:export
Here are the jekyll-related issues:
I receive -bash: jekyll: command not found when trying jekyll serve and when running bundle exec jekyll serve it returns Could not locate Gemfile or .bundle/ directory.
I think another issue compounding this is that I installed jekyll globally when trying to update it. I notice that it pops up with all of its dependancies when running gem list
For reference - check out what I get when I run gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x86_64-darwin19]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/will/.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/will/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-19
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/will/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.0/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
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- export
Please help me get my system back to square one. I'm way in over my head and just want a do over.
My recommendation is to clear all those ruby paths from your PATH, remove every version of Ruby that you have installed and begin again with https://github.com/rbenv/rbenv
Install whatever versions of Ruby you need, and then use bundler to manage your gems https://jekyllrb.com/tutorials/using-jekyll-with-bundler/
Invoke jekyll using bundle exec jekyll and you should be back in business.
I installed the Hanami gem and ran hanami new bookshelf but got
zsh: command not found: hanami
I'm running:
macos 10.15.1
homebrew: 2.1.16
ruby: 2.6.5p114
rubygem: 3.0.6
hanami: 1.3.3
Does anyone know how to resolve this?
Same issue here; with a fresh installed MacOS Sierra, ruby & etc.
gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.6
- RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/captainhusaynpenguin/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin
- SPEC CACHE DIRECTORY: /Users/captainhusaynpenguin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.6.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.6.0
- /Users/captainhusaynpenguin/.gem/ruby/2.6.0
- /usr/local/Cellar/ruby/2.6.5/lib/ruby/gems/2.6.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
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
and finally, with the answer to a similar question by rubiii:
adding the EXECUTABLE DIRECTORY to PATH was the solution.
Quick command from above example:
export PATH=$PATH:/usr/local/lib/ruby/gems/2.6.0/bin
For permanently adding it to path:
sudo nano /etc/paths
was the fix.
I am trying to create a rails app and fails like so:
$ rails new blog
Rails 6 requires Ruby 2.5.0 or newer.
You're running:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
However, my ruby version is 2.6.3 according to my system:
$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ which ruby
/Users/flaab/.rbenv/shims/ruby
Rbenv has 2.6.5 activated.
$ rbenv versions
system
* 2.6.5 (set by /Users/flaab/.ruby-version)
mruby-dev
But it recognizes the wrong one as well.
$ which -a ruby
/Users/flaab/.rbenv/shims/ruby
/usr/bin/ruby
My gem env is...
flaab#MBP-de-Arturo ~ $ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/flaab/.gem
- USER INSTALLATION DIRECTORY: /Users/flaab/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /Users/flaab/.rbenv/versions/2.6.5/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/flaab/.gem/bin
- SPEC CACHE DIRECTORY: /Users/flaab/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/flaab/.rbenv/versions/2.6.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/flaab/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "echo \"gem" => "--no-document\" > ~/.gemrc"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/flaab/.rbenv/versions/2.6.5/bin
- /opt/local/libexec/rbenv
- /Users/flaab/.rbenv/shims
- /usr/local/bin
- /opt/local/bin
- /opt/local/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/flaab/bin
- /Users/flaab/.rbenv/shims
- /sw/bin
- /Users/flaab/.local/lib/npm/bin
- /Users/flaab/.composer/vendor/bin
How can I instruct gem to use the 2.6.5 version of ruby mentioned above?
Thanks in advance
To no avail. Ditched mac and went back to developing on debian. No issues.
Either run rbenv global 2.5.0 to set your global ruby or create a .ruby-version file in the app directory to instruct rbenv to use a specific version.
echo "2.5.0" >> .ruby-version and then try again.
Documentation
Do you have this already added to your .bash_profile ?
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
If not add the above lines to the bottom of the file, then close and restart your terminal(s).
It looks like your EXECUTABLE DIRECTORY may not be set correctly. Try the following command:
rbenv shell 2.6.5
Also, make sure you're in a new empty directory and do
rbenv local 2.6.5
Then try rails command again
rails new blog
I having trouble getting Ruby gems to work right with TextMate (TM) and chruby on macOS.
Clean install of Mojave (now v10.14.4) on a 2017 iMac about six months ago.
Trying to use Ruby-2.6.2, although earlier versions have been installed. System Ruby is v2.3.7
I have ended up with gems in at least three locations:
~/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/
~/.gem/ruby/2.6.2/gems/
/Library/Ruby/Gems/2.3.0/gems/
TextMate relies on its Preferences for gem and Ruby locations. As a start I have the following:
GEM_HOME is unset because I don't see why it's needed, although I've frequently read to set it as shown or similar. GEM_HOME and GEM_PATH are defined as
GEM_PATH provides the locations (there may be several) where gems can be found.
GEM_HOME is where gems will be installed (by default).
The problem is that when I run this script (after the error not included) in TM
#!/usr/bin/env ruby
system ('gem env') # for debugging
puts "\nGem.path: #{Gem.path}"
puts "\ngem list:"
system ('gem list') # for debugging
require 'fileutils'
include FileUtils
require 'find'
require 'yaml'
require "time"
require 'irb'
require 'mini_exiftool'
The result is:
Running “PhotoName-GPScoord.rb”…
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
Theme:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/gscar/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/gscar
- /.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0
- /.gem/ruby/2.6.2/gems/
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/gscar/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin
- /usr/local/bin
- /usr/texbin
- /opt/local/bin
Gem.path: ["/Users/gscar", "/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0", "/.gem/ruby/2.6.2/gems/", "/Users/gscar/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0"]
gem list:
<about 100 gems>
mimemagic (0.3.3)
mini_exiftool (2.9.0)
mini_magick (4.6.1)
<about 20 gems>
LoadError: cannot load such file — mini_exiftool
method require in kernel_require.rb at line 54
method require in kernel_require.rb at line 54
method <main> in PhotoName-GPScoord.rb at line 19
copy output
TextMate puts this in the top right of the output
Line 19 is require 'mini_exiftool'
mini_exiftool is in the gem list, but why the error?
If I run the script using the system Ruby (taking defaults, nothing set in TM)
The script runs with the following output:
Running “PhotoName-GPScoord.rb”…
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Theme:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/gscar/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/gscar/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/gscar/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin
Gem.path: ["/Users/gscar/.gem/ruby/2.3.0", "/Library/Ruby/Gems/2.3.0", "/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0"]
gem list:
<long list of gems including mini_exiftool (2.9.0)>
This particular script is OK with 2.3.7, but others may not be.
Thanks for any help.
This posting is a simplification of an earlier posting from me. I think I've boiled the problem down.
Changed GEM_HOME and GEM_PATH to $HOME/.gem/ruby/2.6.2:$HOME/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0 based on copying the those variables from what showing up when running from the terminal. Lu's comment made me look a little harder at what was being reported. Basically I was missing $HOME/ in the second path (after the colon). I have been fiddling with this for months
I have a gem I have built with an executable. The executable is under the bin directory of my repo and it is defined in the gemspec file:
spec.executables << 'my_gem'
After installing the gem the executable is also installed correctly:
$ ls /Users/myuser/.gems/gems/my_gem-1.0.0/
bin/ lib/
$ ls /Users/myuser/.gems/gems/my_gem-1.0.0/bin/
my_gem*
However I want to add this executable in the path so I can run something along the lines of my_gem or bundle exec my_gem to run the executable from the cli.
What do I need to add to my gemspec file to do this?
Here is my ruby version and ruby gems versions:
$ ruby -v
ruby 2.1.1p76
$ gem -v
2.2.2
Here is my gem env:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin15.0]
- INSTALLATION DIRECTORY: /Users/myuser/.gems
- RUBY EXECUTABLE: /Users/myuser/.rbenv/versions/2.1.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/myuser/.gems/bin
- SPEC CACHE DIRECTORY: /Users/myuser/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/myuser/.gems
- /Users/myuser/.gem/ruby/2.1.0
- /Users/myuser/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://rubygems.org/", "https://my.org.url/artifactory/api/gems/gem-public/"]
- REMOTE SOURCES:
- https://rubygems.org/
- https://my.org.url/artifactory/api/gems/gem-public/
- SHELL PATH:
- /Users/myuser/.rbenv/versions/2.1.1/bin
- /usr/local/Cellar/rbenv/1.0.0/libexec
- /Users/myuser/.rbenv/shims
- /Users/myuser/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
The weird thing is that I already attempted this with a different gem I created using the gem tutorial and that works just fine.
Update: When debugging this for some reason it's running the lib/my_gem.rb file instead of the bin/my_gem file.
The gem has been installed properly. The issue is actually with the executable.
The executable I created ended with this common if statement:
if $PROGRAM_NAME == __FILE__
main
end
To fix it I just had to change it to this:
main