I am working on a Ruby on Rails project. I have everything set up but when I am trying to start the server by doing "rails s" I am getting the following error:
/home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/browser.rb:9:in `require_relative': /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/accept_language.rb:37: syntax error, unexpected '.' (SyntaxError)
code&.downcase
^
/home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/accept_language.rb:44: syntax error, unexpected '.'
region&.upcase
^
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/browser.rb:9:in `<top (required)>'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser.rb:3:in `require_relative'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser.rb:3:in `<top (required)>'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:81:in `require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:76:in `each'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:76:in `block in require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:65:in `each'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:65:in `require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler.rb:114:in `require'
from /home/syed/Desktop/offerletter/config/application.rb:9:in `<top (required)>'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Things thats I have tried:
bundle install
bundle update
1.Ubuntu version - 20.4 LTS
2.rails - 4.2.2 (have to maintain this version due to various reasons)
3.ruby - 2.2.2 (have to maintain this version due to various reasons)
Note: Please ask in comments section If you need any futher information from me to solve the issue.
Kindly please help.
The safe navigator (&.) was introduced in Ruby 2.3.0, and you're using Ruby 2.2.0.
Please use try method or upgrade the Ruby version to 2.3.0+ for using safe navigator.
If the version of Ruby you're forced to use is too old for the safe navigator (&.) you can go oldschool with
code.downcase if code
or use the try() method
Related
I just imported a 5 years old rails project on my ubuntu 18.04 server. I downloaded all the requirements such as ruby 2.0.0 or rails 3.2.22 and all the gems.
At the moment I'm trying to run: rails app:update which gives me the following error (the same when I run rail s) :
/usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `require': /usr/local/rvm/gems/ruby-2.0.0-p648/gems/coverband-5.1.0/lib/coverband.rb:83: syntax error, unexpected '.' (SyntaxError)
(Rake&.application&.top_level_tasks ...
^
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `each'
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `block in require'
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:65:in `each'
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:65:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler.rb:114:in `require'
from /home/ project/apps/current/config/application.rb:9:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:53:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I also get an error when I try to run: rake migrate
rake aborted!
SyntaxError: /usr/local/rvm/gems/ruby-2.0.0-p648/gems/coverband-5.1.0/lib/coverb and.rb:83: syntax error, unexpected '.'
(Rake&.application&.top_level_tasks ...
^
/home/ project/apps/current/config/application.rb:9:in `<top (required)>'
/home/ project/apps/current/Rakefile:5:in `require'
/home/ project/apps/current/Rakefile:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:22:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:22:in `<main>'
Thanks for your help!
The safe navigation operator (&.) was added in Ruby 2.3.0.
Some of the code that changed by running rails app:update uses it.
Hence you first need to upgrade your Ruby version to 2.3.0+.
Rails upgrades and Ruby version requirements
I'm using Rails 5.0.1. I want to run a background process, independent of my Rails server. I thought the workling plugin would helhp me out -- https://github.com/ascarter/workling . However, upon adding this Gem to my Gemfile
gem 'workling'
and restarting my server, I get this error
Gem Load Error is: uninitialized constant ActiveSupport::CoreExtensions
Backtrace for gem load error is:
/Users/davea/.rvm/gems/ruby-2.4.0/gems/workling-0.4.9.9/lib/workling.rb:16:in `<class:Hash>'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/workling-0.4.9.9/lib/workling.rb:15:in `<top (required)>'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `require'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `each'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `block in require'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `each'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
/Users/davea/.rvm/gems/ruby-2.4.0#global/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
/Users/davea/Documents/workspace/myproject/config/application.rb:7:in `<top (required)>'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:156:in `require'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:156:in `require_application_and_environment!'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:77:in `console'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/Users/davea/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
The last commit in workling repo you posted was on Jun 2008. The one RubyGems is using is from February 2009. Either way, R.I.P and there is no point trying to make it work with Rails 5 app :( I strongly recommend checking younger and actively maintained gems, like sidekiq, resque, delayed_job or many others.
Just installed Ruby on Rails 5 on Windows 10. I tried to run the rails server but it gave me the error below. I've tried a bunch of different solutions but nothing seems to work, probably because most of the suggestions were before RoR4. I've updated my PATH/environment variable and extracted the DLL and executable from the sqlite website and put that into my directory, ran bundle install...
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
from C:/Users/Tim/Documents/GitHub/event-registration-system/config/application.rb:7:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `block in server'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I ended up just uninstalling everything and then using RailsInstaller to set up my Rails environment for Windows and this problem was resolved. Rails 5 does work with sqlite now.
I'm not sure what the problem was, but this was the solution that worked for me. Wanted to post it here in case anyone else was experiencing this on the newer versions of the language or framework.
I've installed the latest version of Sublime Text 3 and https://github.com/shuky19/sublime_debugger.
I've followed the instructions, however when I run the debugger, I get the following error:
/Users/sauron/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs/runtimes.rb:65:in `from_environment': Node.js (V8) runtime is not available on this system (ExecJS::RuntimeUnavailable)
Everything works fine when I run 'rails s' directly on the command line.
Here's the console output. The stack trace gets triggered when I try to make a request to the server with my browser.
Started process command: bash -c "'/Users/sauron/Library/Application Support/Sublime Text 3/Packages/Ruby Debugger/ruby_executor.sh' 'rvm' True '-C/Users/sauron/git/sja' '-r/Users/sauron/Library/Application Support/Sublime Text 3/Packages/Ruby Debugger/sublime_debug_require.rb' '-rbundler/setup' '/Users/sauron/.rvm/gems/ruby-2.1.4/bin/rails' s"
Connecting...
----------------------------------------
------------Ruby Executor---------------
----------------------------------------
Method: RVM
Using ruby version: ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin13.0]
Located at: /Users/sauron/.rvm/rubies/ruby-2.1.4/bin/ruby
Ruby Arguments = -C/Users/sauron/git/sja -r/Users/sauron/Library/Application Support/Sublime Text 3/Packages/Ruby Debugger/sublime_debug_require.rb -rbundler/setup /Users/sauron/.rvm/gems/ruby-2.1.4/bin/rails s
Connected
/Users/sauron/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs/runtimes.rb:65:in `from_environment': Node.js (V8) runtime is not available on this system (ExecJS::RuntimeUnavailable)
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs/runtimes.rb:50:in `autodetect'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs.rb:5:in `<module:ExecJS>'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs.rb:4:in `<top (required)>'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/uglifier-2.7.0/lib/uglifier.rb:3:in `require'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/uglifier-2.7.0/lib/uglifier.rb:3:in `<top (required)>'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in `require'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in `each'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in `block in require'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in `each'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in `require'
from /Users/sauron/.rvm/gems/ruby-2.1.4#global/gems/bundler-1.7.6/lib/bundler.rb:133:in `require'
from /Users/sauron/git/sja/config/application.rb:15:in `<top (required)>'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/sauron/git/sja/bin/rails:8:in `require'
from /Users/sauron/git/sja/bin/rails:8:in `<top (required)>'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/client/rails.rb:27:in `load'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/client/rails.rb:27:in `call'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/client/command.rb:7:in `call'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/client.rb:26:in `run'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/bin/spring:48:in `<top (required)>'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/binstub.rb:11:in `load'
from /Users/sauron/.rvm/gems/ruby-2.1.4/gems/spring-1.2.0/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/sauron/git/sja/bin/spring:16:in `require'
from /Users/sauron/git/sja/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Debugger stopped
Looks like I found the answer with a bit of searching on Stack overflow.
See: https://stackoverflow.com/a/24020042/2091901
I'm guessing that the runtime scripts for Sublime Text 3 debugger in question sets the environment variables and has an incorrect reference to the location of node.
In short, I created the following symlink and all is good:
ln -s /usr/local/bin/node /usr/bin/node
Actually. This does not completely solve my problem. I now get this error when servicing a request:
Connected
/Users/sauron/.rvm/gems/ruby-2.1.4/bin/rails:19: syntax error, unexpected '=', expecting keyword_end
Last exception: #
/Users/sauron/.rvm/gems/ruby-2.1.4/bin/rails:23: syntax error, unexpected end-of-input, expecting keyword_end
I am having real trouble trying to get TinyTDS working with Ruby 2.0.0 on Windows 7.
When i run a rails c (or require tiny_tds from an irb), i get the following:
D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- tiny_tds/tiny_tds (LoadError)
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/tiny_tds-0.5.1-x86-mingw32/lib/tiny_tds.rb:16:in `rescue in <top (required)>'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/tiny_tds-0.5.1-x86-mingw32/lib/tiny_tds.rb:12:in `<top (required)>'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from S:/code/user/app/ruby2_test/config/application.rb:7:in `<top (required)>'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:39:in `require'
from D:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have tried installing the latest version of the gem:
gem install tiny_tds --pre
And looking inside:
D:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\tiny_tds-0.6.0.rc1-x86-mingw32\lib\tiny_tds
I can see there is no 2.0 directory, which leads me to believe version 2.0 isn't supported. However i can see no mention on the TinyTDS github or any other sites about this issue.
So, am i missing something or does TinyTDS currently just not work with Ruby 2.0?
Copying the answer from the comments in order to remove this question from the "Unanswered" filter:
I believe this is an issue with OS that you are using as another
individual had the same issue. As stated I believe this is a
dependency issue with Windows. Please see the comment from MetaSkills
- https://github.com/rails-sqlserver/tiny_tds/issues/110#issuecomment-15503928
~ answer per David