Hi i switched my Ruby on Rails development platform from Windows 7 to Linux (Debian), I copied entire app directory to Linux and run bundle installand the command was successful. Than i run rake db:migrate and it quit with following error:
`mri_21` is not a valid platform. The available options are: [:ruby, :ruby_18, :ruby_19, :mri, :mri_18, :mri_19, :rbx, :jruby, :mswin, :mingw, :mingw_18, :mingw_19]
Than i Googled for the error and found this, i followed the suggested steps, i.e.:
gem update bundler
above command output:
Updating installed gems
Nothing to update
Than: bundle install and this was also successful.
But still getting same error on rake db:migrate
my ruby version: ruby 1.9.3p194
unable to get rails version by rails -v getting the same mri_21 error but in my app's Gemfile i have gem 'rails', '4.1.5'
EDIT: But when i tried bundle exec rake db:migrate it was successful. and than i run bundle exec rails s and app running successfully :
=> Booting Thin
=> Rails 4.1.5 application starting in development on 0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Now my question is, how to get rid of this bundle exec every time, and what's going on with this.
Since bundle exec just fixes the PATH, and GEM_PATH variables, you should have all the gem binaries in the PATH variable before that are specified to wrong versions of rails, and gems. Also set GEM_PATH properly. So you be able to avoid the bundle exec call. All the values you are able to know with calls:
$ bundle exec echo GEM_HOME=$GEM_HOME\; GEM_PATH=$GEM_PATH\; PATH=$PATH
GEM_HOME=/home/malo/.rvm/gems/ruby-2.1.4; GEM_PATH=/home/malo/.rvm/gems/ruby-2.1.4:/home/malo/.rvm/gems/ruby-2.1.4#global; PATH=/home/malo/.rvm/gems/ruby-2.1.4/bin:/home/malo/.rvm/gems/ruby-2.1.4#global/bin:/home/malo/.rvm/rubies/ruby-2.1.4/bin:/home/malo/.rvm/bin:/usr/local/heroku/bin:/home/malo/.rbenv/bin:/home/malo/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/games:/usr/lib/qt4/bin
Related
I'm recently started to use Puma for my production server with nginx, however, when I now try to run my app locally, it tries to run Puma with all my production settings and fails. How can I prevent Puma from running locally?
AFAIK all I've done was added the puma gem to my gemfile, so I don't know how it's accessing my server config (I'm just not too knowledgeable in this area). I have it in my production group:
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'puma'
end
Error:
→ rails s
=> Booting Puma
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[8917] Puma starting in cluster mode...
[8917] * Version 3.4.0 (ruby 2.0.0-p645), codename: Owl Bowl Brawl
[8917] * Min threads: 1, max threads: 6
[8917] * Environment: development
[8917] * Process workers: 1
[8917] * Phased restart available
[8917] * Listening on tcp://localhost:3000
[8917] Use Ctrl-C to stop
/rbenv/versions/2.0.0-p645/lib/ruby/gems/2.0.0/gems/puma-3.4.0/lib/puma/runner.rb:103:in `reopen': No such file or directory - /Users/me/mll/shared/log/puma.stdout.log (Errno::ENOENT)
Additionally, though less important to me right now, is it in my benefit to run Puma locally? If so, any tips/resources on how I can do that?
You need to put puma in your production group. Like this:
group :production do
gem 'puma'
end
That way puma will only be used on production and not development.
Update
Make sure that your bin/rails file looks like this:
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Having the exact same issue with Ben. I try to use web brick on local while developing and testing, and puma in production.
Gem file is perfectly define as puma only sits in production group. 'bin/rails' and 'config/application' are checked, same as #Răzvan Ciocănel suggested. Still boot with 'puma' on local.
At last, have a look into the 'bundle install' gem list, 'puma' is installed along with other 'production' gem. Run 'bundle install --without production' and now local will boot with web brick as ROR default.
I guess as long as puma is bundle installed, it will be loaded on local unless you config something to force it off. So the solution might be to remove the gem in the bundle list in development and test.
Rails 3 project (it keeps hanging around longer than expected...)
I changed from unicorn to puma in the production group of my gemfile.
group :production do
gem 'puma'
end
Then then when trying to run tests, or a dev server (which should have been thin) I got:
C:\Rails Projects\Rep>rails s
Could not find gem 'puma x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
After poking around a bit (including finding this question) I gave up and decided to go ahead and use puma in dev. I ran bundle install and tried running server and voila, thin was working again.
Then I realized I still only had it in the production group--I looked back at the bundle install and nothing was installed, puma still isn't installed. But now that bundle install has been run since the edit to the gemfile, everything works again.
C:\Rails Projects\Rep>rails s
=> Booting Thin
=> Rails 3.2.22.2 application starting in development on http://0.0.0.0:3000
So I guess the 'missing gem' error I wasn't because it was trying to actually run puma but rather some kind of bundler generated error due to unattempted gemfile? Just putting this out in case it speed things up for anyone in similar circumstances who ends up here.
I am trying to quickly set up a rails server. I have an app that I have working an running on my personal computer. Running rails server launches it in localhost:3000 with no issues.
I am trying to start a server on a server to an external IP. So, I followed the instructions here: http://luugiathuy.com/2014/11/setup-nginx-puma-on-ubuntu/ with no issue until I ran: puma -e production -d -b unix:///tmp/app_name.sock --pidfile /tmp/puma.pid and got:
No command 'puma' found, did you mean:
Command 'pump' from package 'pump' (universe)
Command 'pumpa' from package 'pumpa' (universe)
Command 'duma' from package 'duma' (universe)
I have run: gem install puma and bundle install I have added gem 'puma' to my gemfile.
If I visit the external IP of the server I get the nginx error of:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
which makes sense since puma isn't running.
Solved it:
`/bin/bash --login`
I believe this worked because before I was not "logged in" to the user that had puma installed
Just wondering if this can be done. You can specify you want a new rails project to use the postgresql server ike this:
rails new my-new-rails-project -d postgresql
and that takes care of the database yaml file.
Can an option be passed in here to specify puma as the development and production server so the relevant puma.rb configuration file is created?
Something like this:
rails new my-new-rails-project -d postgresql -s puma
By default Rails are using Webrick, but you can include different gem using Gemfile.
For example, you can use Thin (or puma, unicorn, whatever...) gem to your Gemfile and install it with bundler.
gem 'thin', group :development
When you start local server, rails will boot with custom webserver
rails server
=> Booting Thin
=> Rails 4.0.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
There is no option for server configuration in Rails. You can check using below command.
rails new --help
I did:
gem install ruby-debug
Then it installs...
I launched using:
rails server -u -p 3002
(I also tried with -d)
I get this:
=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3002
=> Call with -d to detach
=> Ctrl-C to shutdown server
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Exiting
You need add ruby-debug in your Gemfile
gem 'ruby-debug'
I want use always thin when I start my rails server in development mode.
By default it webrick to use. So I add thin in my Gemfile
gem 'thin', :group => 'development'
Now If I want use it to launch my server in development mode I mandatory define it.
bundle exec rails s thin
If I don't define it, it's always use webrick. So How define using thin by default ?
Instead of rails s just type :
>> thin start -p 3000
Where 3000 is the number of your port.
You can also specify an enviornment :
>> thin start -e production
Assuming you are using bundler 1.0.x and your gems is vendorized:
bundle exec vendor/ruby/1.9.1/bin/thin start