When Running this command
rails new test --api
I found this error
/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt:10: syntax error, unexpected ')', expecting end-of-input (SyntaxError)); if spring_install?
what is the solution??
this error face in 2.5.0 version ,
so you can install ruby 2.5.3
rbenv install -l
this will tell you the versions of ruby like that
2.5.0
2.5.1
2.5.2
2.5.3
2.5.4
2.5.5
2.5.6
2.5.7
then run this
rbenv install 2.5.3
rbenv global 2.5.3
gem install rails
Related
I have Ruby 2.7.2 and Rails 6.1.3.1 installed on my Ubuntu 20.04 machine. However, when I try to test a ruby command using the command below:
irb
a = 1
I get the error below:
/home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.3.5/lib/irb/ruby-lex.rb:50:in block in set_input': undefined method in_pasting?' for Reline::ANSI:Class (NoMethodError)
I am still tryring to fix it, but it's working.
The error was caused by an issue with the reline gem in the Ruby 2.7.2 setup. However, if I switch to another Ruby version (2.6.6) using rbenv global 2.6.6 everything seems to work fine.
Here's how I fixed it:
Solution 1:
Since the reline gem comes with Ruby installations, we will uninstall the ruby 2.7.2 version that is the cause of the issue using rbenv :
rbenv uninstall 2.7.2
Next, reinstall the ruby 2.7.2 version that is the cause of the issue using rbenv :
rbenv install 2.7.2
Afterwhich you will install the version of Bunder and Rails that you are using. In this case, my Rails version is Rails 6.1.3.1:
gem install bundler
gem install rails -v 6.1.3.1
rbenv rehash
You can afterwards, check the version of ruby, bundler and rails that were installed using the command below:
ruby -v
bundler -v
rails -v
This time when you try to test again using irb it should work fine.
Solution 2:
A faster approach will be to uninstall the reline gem in the Ruby 2.7.2 setup using the command below:
gem uninstall reline
And then reinstall it:
gem install reline
Note:
I did not test this to confirm if it fixes the issue.
That's all.
I hope this helps
While attempting to solve another issue identified in this thread:
Error while trying to load the gem 'devise. ActiveSupport: Duration can't be coerced into Integer, I followed the suggested solution and changed my ruby version from 2.4.1 to 2.3.3 using rbenv. I also made similar changes in my Gemfile to reflect the new ruby version. However, when I tried to bundle install again, it throws an error saying that my ruby version is 2.4.1, when my Gem specified 2.3.3. However, running ruby -v shows my ruby version is on 2.3.3.
$ bundle install
Your Ruby version is 2.4.1, but your Gemfile specified 2.3.3
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
Any help here would be appreciated. Thank you!
Gem installation is specific to ruby version, so the bundler you're using is likely installed to your old ruby. Try installing bundler again:
gem install bundler
That should fix your problem.
I'm trying to install Rails 5 on my Mac (El Capitan).
When I type
gem install rails
I get this error message:
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
When I check my Ruby version with Rbenv:
rbenv global
2.3.1
however when I check my Ruby version like this:
ruby -v
I get
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
how can I fix this, so when I want to install rails 5, it's using Ruby 2.3.1
Thanks for your help,
Anthony
I'm getting the following error:
ERROR: Error installing rails:
mime-types-data requires Ruby version >= 2.0.
This happens while installing Rails on Ubuntu using the command:
sudo gem install rails
How can I fix this?
As the error suggests, you need Ruby version 2.0 or later.
You are probably using system ruby. Not sure about Ubuntu 16, but earlier versions used to come with Ruby v1.9.3. You can check your current Ruby version by running the following code in your terminal:
ruby -v
For easier rubies version management, I would highly suggest to use one of the popular ruby version managers:
RVM
rbenv
Install rvm and then install latest stable version.
# Using rvm
rvm install 2.3
# Using rbenv
rbenv install 2.3
The current ruby version in your system is below 2.0.
Try installing ruby 2.0 or higher versions before installing rails.
That will solve the problem.
I was facing the same problem trying to install rails with sudo.
I was getting: ERROR: Error installing mime-types-data: mime-types-data requires Ruby version >= 2.0
The thing is ruby -v gives me ruby 2.2.3p173 while sudo ruby -v gives me ruby 1.9.3p484.
So instead of sudo gem install rails I just did gem install rails and it worked.
Error: mime-types-data requires Ruby version >= 2.0
Notice: You shouldn't install rails with sudo permission.
I'm trying to bundle install a ruby project in Git Bash but I'm getting the above message.
ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i836-mingw32]
gem -v
2.3.0
New to Ruby so its really frustrating. I'm trying to do the project below
http://www.viralrails.com/?p=25
This happens because you are specifying a Ruby version in your Gemfile (2.3.0) and this version is not installed or is not the current or default version.
Don't remove the line ruby '2.3.0' as someone said above. You app may have dependencies to this version. Do the following:
1) Check if you have Ruby 2.3.0 installed. If you are using rvm this may be done by
rvm list
and if you are using rbenv by
rbenv versions
2) If you don't have this Ruby version in your list of installed versions, then install it by issuing the following command
rvm install 2.3.0
and if you are using rbenv by
rbenv install 2.3.0
3) If you already had Ruby 2.3.0 installed or completed step 2 above, enter your app directory and issue the following command
rvm use 2.3.0
and if you are using rbenv by
rbenv local 2.3.0
Then run
bundle install
and I believe things will be ok.
Hope it helps!
Install bundler after installing ruby 2.4.0.
gem install bundler
If you installed bundler before installing ruby 2.4.0 then you should reinstall bundler or update it.
Also if the above command didn't work.
gem update bundler