Truly I don't get it what is wrong. I've got fresh project with Rails 7 and Ruby 3.1.2 which I thought I had installed successfully, based on my iTerm2 console:
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
But after firing up the command spring stop inside my project path I'm getting this weirdo:
➜ merchant-portal git:(main)$ spring stop
rbenv: version `ruby-3.1.2' is not installed (set by /Users/some_user/merchant-portal/.ruby-version)
What's going on?
I tried installing the Ruby 3.1.2 again but I'm getting another weirdo:
$ rbenv install 3.1.2
Downloading ruby-3.1.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
Installing ruby-3.1.2...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.5 using ruby-build 20220726)
Inspect or clean up the working tree at /var/folders/bw/rs138g1n5zv_qwn7_7kggc9r0000gq/T/ruby-build.20220801173008.20865.CTLYIi
Results logged to /var/folders/bw/rs138g1n5zv_qwn7_7kggc9r0000gq/T/ruby-build.20220801173008.20865.log
Last 10 log lines:
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/some_user/.rbenv/versions/3.1.2
--with-openssl-dir=/Users/some_user/.rbenv/versions/3.1.2/openssl
--enable-shared
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/some_user/.rbenv/versions/3.1.2/lib
CPPFLAGS=-I/Users/some_user/.rbenv/versions/3.1.2/include
I've tried to reinstall xcode with:
$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
(...)
Done
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
And again reinstall Ruby 3.1.2 but it shows me the same error:
$ rbenv install 3.1.2
(...)
BUILD FAILED (macOS 12.5 using ruby-build 20220726)
(...)
Last 10 log lines:
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
(...)
I've also tried to:
RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline` --with-libyaml-dir=`brew --prefix libyaml`" rbenv install 3.1.2
But it shows me the same error.
Related
On my local machine I'm using rbenv
When I run bundle install I get:
The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Following files may not be writable, so sudo is needed:
/Library/Ruby/Gems/2.6.0
/Library/Ruby/Gems/2.6.0/build_info
/Library/Ruby/Gems/2.6.0/cache
/Library/Ruby/Gems/2.6.0/doc
/Library/Ruby/Gems/2.6.0/extensions
/Library/Ruby/Gems/2.6.0/gems
/Library/Ruby/Gems/2.6.0/specifications
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5
The problem is, when I run rbenv versions, I get the right version (2.5.5):
system
* 2.5.5 (set by /Users/Mahmoud/dev-reps/non-docker/normal/.ruby-version)
And when I run which ruby, it correctly points to rbenv:
/Users/Mahmoud/.rbenv/shims/ruby
Even ruby -v gives the correct version:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin21]
So persumably, 2.5.5 is the ONLY version I have.
In addition to this I tried all the usual hacks related to bundler:
bundle uninstall, gem uninstall bundler -v 1.17.2
but nothing seems to work.
Another "interesting" fact that I think gives a hint: which bundle gives:
/usr/local/bin/bundle
My question is where is this 2.6.8 coming from? And how can I fix this and start the server?
Finally got it working.
So the key to the problem as well to the solution was the fact that which bundle gave:
/usr/local/bin/bundle
while which ruby gave:
/Users/Mahmoud/.rbenv/shims/ruby
indicating that bundle isn't using ruby from rbenv.
I already had the path set in ~/.bash_profile:
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well and restarted terminal. Now bundle install is working as expected.
After updating ~/.zshrc which bundle gives:
/Users/Mahmoud/.rbenv/shims/bundle
indicating that the problem was just that bundle was using the wrong ruby.
So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. Restart terminal and check if its working now.
for Mac
Switch Ruby version with asdf
asdf shell Ruby 3.1.0 (any version)
Switch Ruby version with chruby
chRuby 3.1.0 (any version)
Switch Ruby version with rbenv
rbenv shell 3.0.0 (any version)
Switch Ruby version with rvm
rvm use 3.0.0 (any version)
for other information https://mac.install.guide/faq/downgrade-ruby/index.html
I was getting the issue
"Fix Your Ruby version is 2.6.8, but your gemfile specified 2.7.6"
So i have the followed the below steps
brew install ruby#2.7
\curl -sSL https://get.rvm.io | bash -s stable
rvm install "ruby-2.7.6"
Open your directory where you are planning to create React-Native project and run
/bin/bash --login
rvm use 2.7.6
Then you will see magic ....Your project will create with no error
Or You can do another thing
npx react-native init ProjectName --skip-install
cd ProjectName
yarn install
cd ios
pod install
cd ..
npx react-native run-ios
Try this (it just now helped me):
Delete this file:
/usr/local/bin/bundle
and try react-native init
Taken from: https://github.com/facebook/react-native/issues/35873#issuecomment-1397186611
I am trying to install Ruby on rails on a Mac Mojave:
$ brew install ruby
Warning: ruby 2.7.1 is already installed and up-to-date
To reinstall 2.7.1, run `brew reinstall ruby`
This shows me that I am running Ruby 2.7.1.
But when I check the version I get:
$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
This tells me I am using Ruby 2.3.7.
I don't understand.
To run Rails I need >= 2.4.4 apparently:
$ sudo gem install rails
.....................
ERROR: Error installing rails:
zeitwerk requires Ruby version >= 2.4.4.
and
$ which ruby
/usr/local/opt/ruby/bin/ruby
So until I get ruby version to at least 2.4.4 I can't run rails.
Update
Install RVM on MAC as follows
$ brew install gpg
$ curl -L https://get.rvm.io | bash -s stable --autolibs=enabled --ruby
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
Got these instructions from:
https://null-byte.wonderhowto.com/how-to/mac-for-hackers-install-rvm-maintain-ruby-environments-macos-0174401/
But then I install Rails:
$ sudo gem install rails
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
and so I tried to crate a Rails project:
$ rails new blah
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
What is going on there? I seem to have successfully installed Rails but cannot create a Rails project.
The output from this command brew install ruby is not telling you that you're running ruby 2.7.1. That just says you already have ruby 2.7.1 installed for brew. But you could have other ruby versions installed in other ways. When you do
ruby -v
ruby executable is looked for in paths listed inside your environment variable PATH, in order. You can see those paths with
echo $PATH
So, managing different versions of ruby is hard and version managers exist for this reason. I suggest you to install rvm
Show messages errors:
Required ruby-2.6.1 is not installed.
To install do: 'rvm install "ruby-2.6.1"'
ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
rails -v
Rails 5.2.2
First of all, I doubt that RVM may not be updated to support this version of Ruby. As I know the following version is supported, you can version by following command and response should match.
rvm --version
1.29.7
If you have updated version then I will do the following to check if RVM has also the same version of ruby installed.
I will check the content of my project root folder's following file
cat .ruby-version
If it has mention same, as rvm is also complaining that I will run the following command on rvm to check if this ruby is really installed in RVM
rvm list
It will show a list of rubies installed and it should include 2.6.1 in the end. If you can't see this list then you probably need to install using the following command
rvm install "ruby-2.6.1"
If it is showing than can you try the following command and see what result comes
rvm use 2.6.1
If all good, then try the following command to see which ruby is being used
which ruby
response must include .rvm/rubies/ mean you are using .rvm ruby otherwise, you may using the system built in ruby.
Just wrote may help you to diagnos issue.
Are you using rbenv? If so, I'd recommend running rvm implode as described here.
if you are using rbenv
see if you have it available in your list :
rbenv install --list | grep 2.6.1
if not, fetch it
cd ~/.rbenv/plugins/ruby-build && git pull && cd -
now if you try again
rbenv install -l | grep 2.6.1
so just run the installation command:
rbenv install 2.6.1
Downloading ruby-2.6.1.tar.bz2... 08:36:17
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.1.tar.bz2
Installing ruby-2.6.1...
Installed ruby-2.6.1 to ~/.rbenv/versions/2.6.1
now you can use it for global or local projects. if local :
rbenv local 2.6.1
I'm trying to install Rails onto my Mac and keep running into a this issue. I have no coding/programming experience and am trying to get set up so I can start learning.
I have gone through everything on install rails.com and am not sure what to do.
Your help is appreciated.
make install failed, exit code 2
Gem files will remain installed in /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Follow the steps below to install ruby on rails on mac osx yosemite.
If that does not work please post the exact errors.
For further details about the installation have a look at https://gorails.com/setup/osx/10.10-yosemite
Installing Homebrew
You might be asked to install the XCode CommandLine Tools - say yes.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
you can browse the available versions using
rbenv install --list
installation using homebrew
brew install rbenv ruby-build
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
# Install Ruby
rbenv install 2.2.1
rbenv global 2.2.1
now ruby is installed and you should be able to run
ruby -v
# ruby 2.2.1...
Installing Rails
you can browse the available versions of rails using
gem list ^rails$ --remove --all
installation
gem install rails -v 4.2.1
to use the rails command run
rbenv rehash
now rails is installed and you should be able run
rails -v
# Rails 4.2.1
I'm trying to get ruby 2.1.4 installed via rbenv for a client project.
Though previously I've been able to install ruby versions through rbenv, after upgrading to Yosemite, I keep getting the following error:
rbenv: no such command 'install'
After digging around, I saw lots of tips about how "install" comes from the ruby-build plugin, which is installed via homebrew:
which ruby-build
/usr/local/bin/ruby-build
I installed rbenv via Homebrew, but when I try use which rbenv, I get:
rbenv () {
typeset command
command="$1"
if [ "$#" -gt 0 ]
then
shift
fi
case "$command" in
(rehash|shell) eval `rbenv "sh-$command" "$#"` ;;
(*) command rbenv "$command" "$#" ;;
esac
}
I have run brew update and brew upgrade rbenv ruby-builder, and it tells me everything is up to date.
Below is my full $PATH:
zsh: no such file or directory: /usr/local/var/rbenv/shims:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/bin
UPDATE: Found another answer with a little deeper digging on github that showed signs of promise, but failed to solve the issue with rbenv. https://github.com/sstephenson/rbenv/issues/610#issuecomment-56240018
I believe 2.1.4 is now installed on my machine, but it installed here:
Successfully installed ruby 2.1.4 into /Users/dannycox/.rubies/ruby-2.1.4
As a result, my bundler won't work with the new ruby 2.0 version and I get the following error when I try to gem install bundle:
Fetching: bundler-1.7.6.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
Still need help to identify why ruby-build isn't playing nice with rbenv...
Make sure to install optional step 5 in the instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Install ruby-build, which provides the rbenv install command that simplifies the process of installing new Ruby versions.
I had similar problem, and trace the problem to ruby-build. So i updated the homebrew and reinstall the ruby-build
> brew update
> brew reinstall ruby-build
Find the ruby version
> brew ls -v ruby-build | grep 2.1.4
then install intended version ruby again
> rbenv install 2.1.4
From your perms error I think you are trying to install to the system ruby, which is the one that comes with Apple OSX. You want to use rbenv to install your own ruby and install gems into that.
Read - https://github.com/rbenv/ruby-build#readme
And use the
rbenv versions
command to show what instance of ruby you are about to install the gems into. If it's system then you need to install your own ruby instance and then use that ruby for gems.