Rails Can't Find NodeJS Even Though it is Installed - ruby-on-rails

When I run "rake assets:clean" I get the error:
ExecJS::RuntimeUnavailable: Node.js (V8) runtime is not available on this system
There are several posts about this, but they all say "install nodejs"
I have installed nodejs though.
$ which nodejs
/usr/bin/nodejs
$ nodejs -v
v0.10.25
And also nodejs legacy
$ which node
/usr/bin/node
$ node -v
v0.10.25
I'm on Ubuntu 14.
$ rake about
...
Ruby version 1.9.3 (x86_64-linux)
RubyGems version 2.4.3
Rack version 1.4
Rails version 3.2.13
JavaScript Runtime Node.js (V8)
Active Record version 3.2.13
....
What is really killing me is that this was working fine until I tried to remove a binstubs warning by cleaning the bin directory.
I've tried to undo everything I did to fix the binstubs issue - going back to a clean version in git, reinstalling rvm, reinstalling ruby, reinstalling my gems. I'm out of ideas on how to fix this.
I wonder if it's something stupid like an issue with my PATH:
$ echo $PATH
/home/andy/.rvm/gems/ruby-1.9.3-p551/bin:/home/andy/.rvm/gems/ruby-1.9.3-p551#global/bin:/home/andy/.rvm/rubies/ruby-1.9.3-p551/bin:/home/andy/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/heroku/bin

I had added "PATH: './bin:$PATH'" to my local_env.yml file. See comment above. Doh!

Related

Your Ruby version is 2.6.8, but your Gemfile specified 2.7.6 error while enabling new architecture on react-native iOS

I have already gone through this post
I am facing this issue on my new react-native project version 0.71.1 while enabling the new architecture for iOS
I have done all the below steps
$ brew update
$ brew install ruby-build
$ brew install rbenv
$ rbenv install 2.7.6
$ rbenv global 2.7.6
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
When I run ruby --version I get ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin22] which is the correct ruby version required to enable new architecture on iOS
but when I run bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install I still get error saying
Your Ruby version is 2.6.10, but your Gemfile specified 2.7.6
What else am I missing?
I have also raised the issue in react native's GitHub repo. This might help in understanding in what I have already tried
I was able to resolve my issue by running bundle install --redownload. It Forces a redownload of all gems on the gemfile, assigning them to the new bundler
Your error message means that the Ruby version specified in your Gemfile is different from the version of Ruby installed in your system.
Try the following steps to solve this issue:
Run command 'which ruby' to confirm the path of the Ruby executable that your system is using.
Check the Ruby version specified in your Gemfile and ensure it matches the
version returned by the 'ruby --version' command.
If the Ruby versions do not match, try to update the version specified in your Gemfile to the version of Ruby installed on your system.
If you have multiple versions of Ruby installed, use the 'rbenv local' command to set the correct version for your project.
If the issue is still there, try reinstalling the required version of Ruby and the related dependencies.
Just change your ruby version in GemFile to 2.6.10 and then try it.
You'll find your GemFile in your project's root directory
The Rbenv documentation can define a version file named .ruby-version inside your project folder. Perhaps you have this file with a specific version number inside.
This setting overrides your default ruby version.
Link to Rbenv-Repo: https://github.com/rbenv/rbenv
Update: After lots of suggestion, we came to the conclusion. The command bundle install --redownload updates the local bundler and everything is fine. :-)

Fix Your Ruby version is 2.6.8, but your gemfile specified 2.5.5

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

How to resolve Rails issue- An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue

you may get this issue while working on Rails 4.0 and above version along with Ruby 2.0 and above.
this is very common issue if you are going ahead with up gradation of Rails environment.
Steps to be follow-
For Windows System-
1.Download the the newest mysql-connector to c:\mysql-connector folder
2. gem install mysql2 -- '--with-mysql-include="C:\mysql-connector\include" --with-mysql-lib="C:\mysql-connector\lib"
Hopefully it will work for you.
For Ubuntu System-
1. open terminal (Ctrl+alt+T)
2. $ sudo apt-get install libmysqld-dev
Run bundle from your project directory
3. $ bundle
This will resolve the issue.We can also see the solution here.
https://randvblog.wordpress.com/2016/06/20/how-to-resolve-rails-issue-an-error-occurred-while-installing-mysql2-0-4-4-and-bundler-cannot-continue-make-sure-that-gem-install-mysql2-v-0-4-4-succeeds-before-bundling/
I got this issue resolved with following steps as-
open terminal (Ctrl+alt+T)
$ sudo apt-get install libmysqld-dev
Run bundle from your project directory
$ bundle
rails s
Now rails app is working fine.

Can't install rails - "File exists # dir_s_mkdir" error

I have had rails installed and almost working. Was working on a solution to another problem with I accidentally closed the bash window. So I reopened it, and now I am unable to use rails at all and it's telling me that rails isn't installed. So I ran gem install rails --no-ri --no-rdocand now I get the following:
ERROR: While executing gem ... (Errno::EEXIST)
File exists # dir_s_mkdir - /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems`
How do I correct this error?
I just removed the broken gems, site_ruby and vendor_ruby symlinks from the /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/ folder and now everything seems to work fine.
I just added a gems/ directory here /usr/local/lib/ruby/ and that solved the issue.
for a temporary solution, you can mkdir -p /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems/2.1.0 to solve.
When you open your bash window (called the "terminal window" or "console"), what folder ("directory") are you in? Find out with:
$ pwd
Navigate to the folder where you created your Rails project using the Unix cd command, for example:
$ cd workspace/learn-rails
If you are using RVM, make sure you have selected the correct gemset:
$ rvm gemset list
gemsets for ruby-2.1.1 (found in ...)
(default)
global
=> learn-rails
Then see if Ruby and Rails are installed:
$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ rails -v
Rails 4.1.0
Refer to the article Install Ruby on Rails for help. If you haven't followed all the steps in the article, you may have problems, especially if you followed some of the inaccurate instructions found elsewhere on the web.
I was recently in this wormhole. It seems like Homebrew's ruby installation has an issue with soft links and uses version 2.1.1. I couldn't "gem install" anything without getting the annoying "File exists # dir_s_mkdir" error. Even tried MacPort and that was a nightmare.
First uninstall ruby via
brew uninstall ruby
or
port uninstall ruby
And follow the instruction on https://rvm.io/rvm/install to install ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
It might then complain about ruby-2.0.0-p353 not installed
To install do:
rvm install ruby-2.0.0-p353
Then run the rvm install script. Your "gem install << whatever >>" should now work
This fixed the issue for me (Homebrew on a Mac, Ruby 2.1.3):
$ brew reinstall ruby
$ brew unlink ruby && brew link ruby
the same issue. I just remove dir_s_mkdir, then pod install. it works for me!

Vanishing Ruby Gems

I'm using Ubuntu 8.10 and I installed Ruby and Ruby on Rails following the directions on this site. The exact directions I followed are no longer there as it appears the rubyonrails.org wiki has changed recently. But I installed it the long way. Installed Ruby, then Gems, then installed Rails using "gem install rails".
I haven't really messed with Rails for a while, and I tried to use the Gem command today and...
The program 'gem' can be found in the following packages:
* rubygems1.8
* rubygems1.9
Try: sudo apt-get install <selected package>
bash: gem: command not found
That's just weird to me because I installed rails using the gem command. I have been seaching my computer for the gems binary so I could create a link to it in the bin directory but I can't find it. I know it's installed becaues when I run 'script/server' and go to localhost:3000 in a browser I get the following version information:
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.3.1
Rails version 2.2.2
Active Record version 2.2.2
Action Pack version 2.2.2
Active Resource version 2.2.2
Action Mailer version 2.2.2
Active Support version 2.2.2
Anyone know how I can get my gem command working again? Thanks for any help.
Note: I am new to Rails and fairly new to Ubuntu and Linux in general.
Did you install rubygems from apt-get? If yes, maybe you should try to remove it and install it from source.
Here is another article on installing Rails on Ubuntu:
http://www.rubyinside.com/how-to-install-a-ruby-18-stack-on-ubuntu-810-from-scratch-1566.html
Essentially, you can install Ruby from apt-get or source, but it's recommended to install rubygems from source.
You could look to see if it's in:
/usr/bin/gem1.8
if it is, then symlink /usr/bin/gem to it:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
BTW, here's another tutorial on how to install rails on Ubuntu 8.10:
http://articles.slicehost.com/2009/1/6/ubuntu-intrepid-ruby-on-rails

Resources