I'm new to Ruby on Rails and I'm trying to start the RoR server. But when I run the command rails server it gives me the following error:
Sorry, you can't use byebug without Readline. To solve this, you need to
rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
install libreadline-dev` and then reinstall your Ruby.
bin/rails:6: warning: already initialized constant APP_PATH
/home/abraar/ror/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
I'm using rbenv with Ruby 2.2.2 and Rails 4.2.1
I tried following the instructions on this blog post http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/ but it's not working.
Any solutions?
Thanks!
To fix this (for OSX, tested on Sierra), run following command in your shell -
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
July 2019 on Mac
I faced this same issue on my machine & running the following command solved it, note that even if you have version 8 of readline you still need to link to version 7 as shown:
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
I solved the issue by (commands for mac with homebrew and rbenv):
installing readline brew install readline
reinstalling / recompiling ruby rbenv install 2.3.1
I was facing the following error:
Sorry, you can't use byebug without Readline
Reinstalling ruby resolved this for me (using rvm):
rvm reinstall 2.1.5
You can replace ruby version ie, 2.1.5 with the one you want to reinstall.
Add this to the development group of gem.
gem 'rb-readline'
https://github.com/deivid-rodriguez/byebug/issues/289#issuecomment-251383465
byebug is a gem used for debugging.
The new app generator for rails includes it by default in the development & test environments with the following lines:
group :development, :test do
<% if RUBY_ENGINE == 'ruby' -%>
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
I don't think it is important for a newcomer to be able to use it. I would recommend commenting out that line in the Gemfile, run bundle install and continue with your rails learning adventure.
I resolved it by follwing way
brew unlink readline
brew link readline --force
If you are in a hurry,
Open your byebug's history.rb
/Users/user/.rvm/gems/ruby-2.1.5#rails/gems/byebug-9.0.5/lib/byebug/history.rb
and comment out the following line,
require 'readline'
But, It is recommended to use byebug to debug.
Related
I get the error:
Cannot start debugger. Gem 'ruby-debug-ide' isn't installed or its executable script 'rdebug-ide' doesn't exist.
but all gems were successfuly installed:
gem 'ruby-debug-ide'
gem 'debase'
I can run 'rdebug-ide' manually:
$ rdebug-ide
Using ruby-debug-base 0.2.1
Usage: rdebug-ide is supposed to be called from RDT, NetBeans, RubyMine, or
the IntelliJ IDEA Ruby plugin. The command line interface to
ruby-debug is rdebug.
But when I start debugging, RubyMine asks to install the ruby-debug-ide gem. Why?
And, after installation I get:
Cannot start debugger. Gem 'ruby-debug-ide' isn't installed or its executable script 'rdebug-ide' doesn't exist.
I'm running Mac OS X 10.11.3.
Here's the actual command that worked for me:
gem install ruby-debug-ide --pre
Complementing Ahsan Ellahi
In your terminal you're probably not running the same ruby version as inside Ruby Mine. You can check this
In Ruby Mine
Preferences --> Laguanges and Frameworks --> Ruby SDK and Gems
In Terminal
$ ruby -v
If you're not running the same version, try to set RubyMine to use the same Ruby version that you're running in your terminal. This should solve the problem. Than, if you really want to use another RubyVersion, you will need to go to your terminal, change the Ruby version and manually install both gems
I have faced this issue when debugging in a docker-compose environment. I suspect that RubyMine does not refresh the list of available gem after the SDK is added.
So if you add the SDK then add ruby-debug-ide to Gemfile you will get the error.
Instead, (re)create the SDK after adding ruby-debug-ide.
I started getting this after upgrading from 2017.x to 2018.1. In my case, it seems that RubyMine needed a newer version but its error message implied it couldn't find any version and failed to install it. I think it was trying to install it with a different SDK.
Manually installing the latest ruby-debugger-ide (in my case the --pre flag was necessary) and then restarting RubyMine did the trick for me.
Since you're using Mac OSX, I couldn't provide the same exact answer for you, but you can find a similar way of achieving this. I'm using Ubuntu with Vagrant, so you may need to adapt it just a little bit.
Copy the following gem from RubyMine/rb/gems app folder, please copy the gem related to your ruby runtime and platform, there are different gems for different ruby runtime and platforms, in my case, its:
debase-0.3.0.beta7.gem
ruby-debug-ide-0.8.0.beta6.gem
Install them inside your app host, in my case its vagrant, in your case it could be inside your container, or in your host OS using the following command:
gem install --force --local *.gem
Set breakpoint and start debugging.
It may asks you one more time to install the gem, but then the debug will works for sure.
This worked for me
gem install debase-ruby_core_source
Source: Cannot install Rubymine Debugger
You should look into RubyMine settings, which ruby version and which gemset (global/default) it is using. Check out where these required gems are installed and make sure RubyMine is using that gemset where these are installed successfully.
I fixed this after viewing the responses here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206072049-Cannot-start-debugger
The solution at the bottom suggested 'removing all my gems. removing ruby. cleaning up directories and rvm. removing ruby mine, then reinstalling everything'
I started with the easiest of these, which was to reinstall rubymine. That solved it for me.
I had this issue on Windows 11 running Ubuntu on WSL2. To solve, I manually copied the relevant files in my %AppData% directory into the corresponding directory in Ubuntu.
I found all the data at:
C:\Users[USER]\AppData\Local\JetBrains\RubyMine[VERSION]\ruby_stubs\[NUMBER]\home\[USER]\.gem\ruby\2.7.0
These files were copied to: \\wsl.localhost\Ubuntu\home\[USER]\.gem\ruby\2.7.0
After doing this, everything worked again.
I have faced this issue too with Rubymine 8, rvm 1.29.1 and Ruby version 2.3.3 And upgrading the Rubymine version from Rubymine 8 to Rubymine 2016.3 or latest resolves the issue for me.
Check ruby SDK's version is right.You can first using rails installer to install everything .
Then using gem to install rdebug for ruby 2+.
Make sure Rubymine's Ruby version is same to which you have installed.With those all done,you will be able to debug ruby.
Please check x286 vs 64 version, both Ruby and Rmine version. I had this problem runnin x86 rubyMine on 64 ruby
A combination of matching the host ide ruby version with the remote SDK version worked for me but required a few additional steps. I too am running mac os as my host (running mohave)
the remote environment setup in preferences -> ruby sdk and gems must have the same version as the remote target, including any gems installed.
NOTE: I had to re-install the bundler gem on both host and remote host to get the gem manager to install things auto-majically.
the project environment must be changed to use the same version as the remote host as well. this is in File -> preferences for new projects -> ruby sdk and gems.
NOTE: I also had to set the default RVM on my local host and remote host and unset the previous version as default in the local host preferences.
Once I did this I was able to get gems in sync and remote debugger to connect.
My solution was to go to Rubymine settings, to the available SDKs,
remove the SDK, restart Rubymine and add the SDK again.
Running Ubuntu 18 something, RubyMine version 2020.3. Had this issue. None of these suggestions worked for me, same error no matter what did. I was using RVM, and ruby 2.6 and 2.7, switched back and forth a cleaning and reinstalling gems along thew way, both debase and ruby-debug-ide were installed according to the gem list. Settings in rubymine matched "ruby -v" from the command line. VSCode worked perfectly with this setup.
In the end i removed RVM and all the ruby versions, installed ruby via rbenv, installed ruby 2.6.5 and that worked like a charm.
I think this error is generated for multiple reasons with no real way to figure out which reason for your specific instance. I would like to encourage jetbrains to generate more debug information on errors like this, or if you are generating error information, point out where it is when this happens.
Try these steps:
1. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. brew install ruby
3. echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
if you get unshallow error on any step then first try:
1. git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
2. git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4. brew install ruby
5. echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
Lastly restart the terminal and check .bash_profile:
- nano ~/.bash_profile
If you see the path variable, just close it. Otherwise it means something went wrong :/.
The last step is to open
RubyMine -> Preferences -> Language and Frameworks -> Ruby SDK and Gems -> select the newest ruby version and apply.
You may need to update ruby version from the gemfile.
And it should be done!
I want to install one Application on my CentOS 5.5 which requires Ruby Enterprise Edition 1.8.7 and Rails 2.3.5.
I have installed REE from rubyenterpriseedition.com. To install my application I need to do some settings.
In my .bash_profile I should change PATH = $PATH:$HOME/bin to
PATH=/opt/ruby-enterprise-1.8.7-2012.02/bin:$PATH:$HOME/bin
then to reload
source .bash_profile
To check whether changes have been reflected, we must run which gem. This has to output output:
/opt/ruby-enterprise-1.8.7-2012.02/bin/gem
But Unfortunately it is outputting
[root#local ~]# which gem
/usr/bin/which: no gem in (/opt/ruby-enterprise-1.8.7-2012.02/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/college/bin:/root/bin)
After that when i do
[root#local ~]# gem update --system
bash: gem: command not found
I am getting above error.
But Look at the Actual PATH Below...
[root#local college]# echo $PATH
/usr/kerberos/sbin:/opt/ruby-enterprise-1.8.7-2012.02/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/college/bin:/root/bin:/opt/ruby-enterprise-1.8.7-2012.02/bin
Please help me out to install this application on my CentOS.
I think you are mixing up versions. I see both 2011.03 and 2012.02 mentioned. Please check which version you actually installed and make sure your PATH variable has this version as well.
I've tried a number of things like uninstalling/reinstalling rails and gems but to no avail.
When I go into my new project and run rails s or bundle exec rails server I'm getting this error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/toabui/Sites/cms/bin/rails:6: warning: previous definition of APP_PATH was here Usage: rails COMMAND [ARGS]
Inside my bin/rails I see this code:
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Does anyone know why I keep getting that error when I run rails s?
I've googled and it seems like there is an error with the spring gem but I can‛t seem to get it to work.
I couldn't find the an_initilizer.rb in my directory and I tried uninstalling/installing the spring gem but it didn't work.
However I did managed to finally get it working.
Apparently there is some conflict with spring and rails 4+.
I needed to run:
rake rails:update:bin
But I ran across another error:
Library not loaded: libmysqlclient.18.dylib
I ran the following command which I found on another stackoverflow post:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Then ran the original command:
rake rails:update:bin
Then run the server command:
rails s
And now my WebBrick Server is running.
rake rails:update:bin to the rescue.
If you are on El Capitan (OS X 10.11), Security Integrity Protection (SIP) will prevent linking into /usr/lib to fix mysql. Link it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
This is work for me.
gem uninstall mysql2
bundle install or gem install mysql2
I was getting the same error. Removed spring from Gemfile and re-bundled. Not really a solution though.
I found the code that created this error in config/initializers/an_initializer.rb
require "lib/a_file_i_need"
I changed it for
require "#{ Rails.root }/lib/a_file_i_need"
I got this error by trying to update rails 4 and imagemagick and rmagick.
So I just ran
gem uninstall rmagick
Select the All Versions option. Then try again
EDIT: This happaned again with me just now because I tried to use a gem without installing the required base gem. In my case the solution was to install 'omniauth-google' before trying to use 'omniauth-google-oauth2', but because I didn't install I got the same error again
I got the same error. I had ruby 2.1.3 and rails 4.1.6 running on Mavericks and then I migrated to Yosemite and installed the 4.2.0 rails version an ruby 2.1.5 and my apps I made in the previous version didn't work with the new one, so I made some gem sets with RVM and installed the 2.1.3 version.
Now when I wanted to run the server I got these error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
And as tobu mentioned I ran:
rake rails:update:bin
I got this:
LoadError: dlopen(/Users/Lexynux/.rvm/gems/ruby-2.1.3#SAIIP2/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Then I ran this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
And finally I repeated the first command it the terminal asked me for this:
Overwrite /Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails? (enter "h" for help) [Ynaqdh]
I just typed 'Y' and hit return.
After all this I started working and going well.
Thanks.
I received this error after upgrading postgresql.
$ gem uninstall pg
$ gem install pg
resolved this issue for me.
This happened to me after doing a brew upgrade. My guess is that this broke some gems with native extensions, even though there was no error message pointing to that.
What I ended up doing was completely removing my installed gems (In my case I completely uninstalled and reinstalled the ruby version using rbenv).
Running bundle install recompiled the native extensions, and everything was running again.
I'll post what worked for me.
Comment out
gem 'spring'
Add gem 'net-shh'
and run bundle install
And restart your sever
I got the same error, it happend to be related to gem dotenv.
Instructions were to add the following to Gemfile:
gem 'dotenv', :require => 'dotenv/rails-now'
But as it turned out, dotenv/rails-now caused the error. If you use dotenv don't require rails-now
Are you using pg and mysql in different branches ? If yes, please confirm db config file.
I received this error after upgrading rails. Disabling spring give me a hint that the issue was with:
gem 'google-api-client', require: 'google/api_client'
Changed to:
gem 'google-api-client', '0.9'
Resolved the issue.
I had the same error message output when trying to start an application within a Vagrant environment. It cropped up out of nowhere after zero changes to the application code (and other weird behaviour followed, such as development.rb being deleted upon attempting to run the app).
In the end I simply halted the VM & restarted it, everything was then fine so I'm assuming it was an issue with file syncing / shared folders perhaps? (default Vagrant shared folder being used).
Run these in console:
rake tmp:clear
rake secret
IF rake rails:update:bin gives additional errors:
I had recently been doing some server maintenance and had subsequently updated OpenSSL.
When I tried running the rake rails:update:bin command, I was presented with an error relating to openSSL.
Having rebuilt my version of Ruby (`rvm reinstall ruby-x.x.x' with RVM), both errors went away.
This is always worth a try I guess.
My problem was I was using an outdated version of ruby 1.9.3 with rails 4.2. I upgraded to 2.1.2 , removed the broken project, ran rails new blog to recreate my project, navigated into my newly created app and ran rails server and it worked.
I just had this problem and found that it was being caused by the fact that I had removed a gem from the gemfile without deleting the other require references. In my case, I just had to remove it from config/application.rb.
Had this error recently, it is caused by spring, because of its suggested code in executables:
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
It originally expects a LoadError for spring itself in production, but by this code all other load error will be ignored too.
Thus if you have any other LoadError in rails loading process (for example in routes/init) spring worker startup fails and then there goes branch that tries to load everything again like there was no spring.
For me this issue presented as a result of bundle upgrading rvm-capistrano amongst other things.
Adding this require:false fixed things in the end as per this previous post
gem 'rvm-capistrano', require: false
Although could possibly be an additional issue - as running rake rails:update:bin may have helped clear the initial issue.
Im about to start work on another web application, I change directories to
/rails_projects
and enter
rails new blank
I then get this error
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I have reinstalled rails, and still same error, any ideas?
UPDATE:
It actually give me the same error when I type just
rails -h
rails
in cmd
For anyone with a similar error that may land here, this fixed it for me:
rake rails:update:bin
This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.
I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.
The culprit was the presence of script/rails which contained:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.
I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.
It looks like the rails command believes it's inside of a rails engine, which is why a different set of commands are available to you. Notice the 'commands available for engines' text. New is not a command available for engines. I'm not sure why rails thinks the directory you're in is an engine, but likely your directory structure is mixed up somehow.
If anyone runs into this error and needs a last resort plan.
I ended up uninstalling rails, rvm, and installing a newer version of ruby and new gemset.
rvm implode
gem uninstall rails -v=4.0.2
gem uninstall railities
install rvm :
curl -L https://get.rvm.io | bash -s
rvm get stable
for mac:
brew install libtool libxslt libksba openssl
brew install libyaml
install ruby:
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
if you have error
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/opt/openssl
install new ruby gems from website. Unpackage it then go to folder and run
ruby setup.rb
gem update --system 2.1.9
install rails (you can choose your version)
gem install rails --version 4.0.2
gem install railties
I did this, and now system is working normal again.
Create another directory and run $ruby -v, check which version is available. Now run rails new app_name. Try once after closing the terminal and restarting.
This happen to me when a require error occurred in a gem (dependency) while loading.
I am trying to run a
rails new demo
But am told:
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.
I run that command, and many 'fetching' lines followed by many 'Installing RDoc documentation for...' are run, but then the last lines say:
Installing RDoc documentation for rails-3.2.13...
file 'lib' not found
and then it stops running, and the 'rails' command (see above) doesn't work still. Why is Rails not installed? What else should I do? Thanks
Looks like this is rdoc related. Short version, try :
gem install rdoc
And then launch the install of rails again.
Look at this answer that seems to have helper a lot of people with this exact problem.
I solved it: apparently I was trying to install rails in the directory. I did the following and it worked well:
cd /
Then I ran
sudo gem install rails
Then I cd into the relevant directory again and now
rails new demo
worked!
It's not a good idea to do a 'sudo gem install rails' since you may experience permission problems with your applications in the future.
I would recommend you using RVM which is a ruby version manager. You can easily install different versions of Rubies, you can create application specific gemset's and minimize possible futuristic 'rails is not currently installed' errors.
I highly recommend you searching and reading about these concepts:
RVM
Gemsets
.rvmrc
.bashrc and .bash_profile