Problems running rails server - ruby-on-rails

I just installed the rails env using the Rails installer on my Mac OSX 10.7.4.
I create a project using the "rails new" command.
When I try to run the "rails server" command I get this message:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:90:in `<class:Base>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:85:in `<module:Generator>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:48:in `<module:Rails>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator.rb:37:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/bin/rails:15:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/rails:23:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/rails:23:in `<main>'
When I run the $ ruby -v and $ gem -v, I get "ruby 1.9.3p194" and "1.8.24" respectively. What am I missing here? How can I get this server to run?

It looks like you are trying to use a Rails 3.x command with Rails 2.3. Pre 3.0 you have to use the server script.
From within your application directory run:
./script/server

Install rails as a gem, gem install rails . As your are using rvm, the folder path displayed here shows rails 2.3.4, while you tried to run rails server . Check/change the rails version in your gem file and then do bundle install.

Related

WKHTMLTOPDF PDF could not be generated

My rails app is working fine in many aspects but when I try to generate pdf on a production server, I get this error below. On my local computer, it's working fine. How can I go about this?.
Command Error: /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/definition.rb:495:in `validate_ruby!': Your Ruby version is 2.7.0, but your Gemfile specified 2.7.2 (Bundler::RubyVersionMismatch)
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/definition.rb:470:in `validate_runtime!'
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler.rb:143:in `setup'
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/setup.rb:20:in `block in <top (required)>'
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/ui/shell.rb:136:in `with_level'
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/ui/shell.rb:88:in `silence'
from /home/deploy/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/setup.rb:20:in `<top (required)>'
from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'```
Note that am using ruby 2.7.2 and I dont have ruby 2.7.0
Try to delete "bundle" folder in your app root (on production server), and run "bundle" or "bundle install" afterwards. Solved this issue for me some time ago.

rake db create aborted

I have been trying to fix my project using Ruby 2.3.8, I am using rvm to install Ruby 2.3.8 but need extra works to install that on my mac because 2.3.8 need can't resolve with openssl 1.1. So I need to find how to install openssl 1.0 because Homebrew deleted the openssl 1.0 so it needs extra research to fix that.
In my project I am using MySQL 5.7 and to install MySQL 5.7 I need to install OpenSSL 1.1 again, so it automatically installs OpenSSL 1.1
When I go to my project and doing rake db:create I got error like this:
rake aborted!
LoadError: library not found for class Digest::SHA1 -- digest/sha1
/Users/hoomacbuk/Documents/mekari/quickbook/config/boot.rb:4:in `<top (required)>'
/Users/hoomacbuk/Documents/mekari/quickbook/config/application.rb:1:in `<top (required)>'
/Users/hoomacbuk/Documents/mekari/quickbook/Rakefile:4:in `<top (required)>'
/Users/hoomacbuk/.rvm/gems/ruby-2.3.8/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
Caused by:
LoadError: dlopen(/Users/hoomacbuk/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/x86_64-darwin18/digest/sha1.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /Users/hoomacbuk/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/x86_64-darwin18/digest/sha1.bundle
Reason: image not found - /Users/hoomacbuk/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/x86_64-darwin18/digest/sha1.bundle
/Users/hoomacbuk/Documents/mekari/quickbook/config/boot.rb:4:in `<top (required)>'
/Users/hoomacbuk/Documents/mekari/quickbook/config/application.rb:1:in `<top (required)>'
/Users/hoomacbuk/Documents/mekari/quickbook/Rakefile:4:in `<top (required)>'
/Users/hoomacbuk/.rvm/gems/ruby-2.3.8/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
And when I running bin/rake db:create I got this error again :
/Users/hoomacbuk/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/digest.rb:16:in `const_missing': library not found for class Digest::SHA1 -- digest/sha1 (LoadError)
How can I get Ruby 2.3.x to run? I
There seems to be an issue with your ruby version.
Uninstall the current version and reinstall the same one and then try again.
rvm uninstall 2.3.8
and then
rvm install 2.3.8

$ rails -T & $ rails server (puma) is failing

I have a rails 5.2.0 set up on my macos catalina with rbenv 1.1.2/ruby 2.5.1. At the root of my app I get the following error:
$ rails -T
rails aborted!
LoadError: dlopen(/Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.11.1/lib/ffi_c.bundle, 9): Symbol not found: _ffi_type_double
Referenced from: /Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.11.1/lib/ffi_c.bundle
Expected in: flat namespace
in /Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.11.1/lib/ffi_c.bundle - /Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.11.1/lib/ffi_c.bundle
/Users/sa/Projects/ror/bubblin.io/bubblin.io/config/application.rb:7:in `<top (required)>'
/Users/sa/Projects/ror/bubblin.io/bubblin.io/Rakefile:1:in `<top (required)>'
bin/rails:4:in `<main>'
Caused by:
LoadError: cannot load such file -- 2.5/ffi_c
/Users/sa/Projects/ror/bubblin.io/bubblin.io/config/application.rb:7:in `<top (required)>'
/Users/sa/Projects/ror/bubblin.io/bubblin.io/Rakefile:1:in `<top (required)>'
bin/rails:4:in `<main>'
Caused by:
Bootsnap::LoadPathCache::FallbackScan:
(See full trace by running task with --trace)
I can provide the full trace but just to know I reinstalled everything from scratch and my xcode-command-line tools/gcc are up-to-date. Is this something that has come up/been solved before?
After struggling for a week with this issue, I was forced to uninstall rbenv and purge all rubies under rbenv from my machine. I am now using the system rubies instead. My macbook pro has ruby 2.6.5 by default, so I bumped up the .ruby-version on my app from 2.5.1 to 2.6.7 to make sure i was on a development environment that “worked.”

Rails console not working even after updates

I am trying to run rails console. I have tried everything suggested on SO. I have libreadline-6 installed. My ruby version is 2.1.1 and irb is 0.9.6.
/home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Any suggestions?
Also, I am using rbenv to manage my ruby versions.
You need to install libreadline and also the -dev package and then you need to recompile ruby. When your using rvm you should always run
rvm requirements
first and then download and compile ruby. If your using rvm then you can run
rvm reinstall <version>
to do this.
// Also see: http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/

RubyMine errors after creating 'Rails application' project

I've downloaded and installed "rubyinstaller-1.9.2-p180.exe", then I installed gems(rubygems-1.6.2 by running 'ruby setup.rb') and the installed rails by running 'gem install rails'.
After doing all this, I've downloaded and installed RubyMine 3.1
In RubyMine I try to create new 'Rails Application' project, in the 'Rails application settings' dialog it shows above installed rub as the Ruby Interpreter, Rails Version says '3.0.5'. Rails Template is empty. 'Preconfigure for selected databases' is unchecked, and also "skip test:unit files' is unchecked.
After clicking ok, it creates some files at the top of the code there is a message "some of the required getms are note attached: sqlite3"( I didn't ask DB, so why sqlite??) anyway I click, on 'attach gems'.
After that I click on play icon, and get below errors. Please help me resolve this issues. Thanks in advance!
------------------------------
C:\Ruby192\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/kobi/RubymineProjects/deded/script/rails server -b 127.0.0.1 -p 3000 -e development
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
from C:/Users/kobi/RubymineProjects/deded/config/application.rb:7:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `block in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `<top (required)>'
from C:/Users/kobi/RubymineProjects/deded/script/rails:6:in `require'
from C:/Users/kobi/RubymineProjects/deded/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
RubyInstaller for Ruby 1.9.2 doesn't support any other RubyGems version except the one which comes with the RubyInstaller. By updating RubyGems you break your Ruby installation. Please reinstall Ruby into the clean directory and don't update RubyGems.
Also, it looks like sqlite3.dll is missing from your PATH environment. Download it and unpack into RUBY_HOME\bin or c:\windows\system32. Rails needs some database and sqlite is the default.
Some native gem extensions may require DevKit installed, if you have problems installing such gems, install DevKit first.
Try this from console:
cd C:/users/kobi/rubymineprojects/deded
bundle install

Resources