Is Rails supported on Now?
OS: OSX 10.14.6
Node: 10.16.0
Ruby: 2.6.1
Now CLI 16.1
Rails: 6.0
Hi,
I'm having issues running Rails locally using now dev and on now.
Locally with now dev
Reproduction steps:
rails new rails-app- Create a
now.jsonwith contents:
{
"version": 2,
"builds": [
{
"src": "rails-app/config.ru",
"use": "@now/ruby"
}
],
"routes": [{ "src": "/", "dest": "rails-app/config.ru" }]
}
now devyields:
> Creating initial build
> Error! Command failed with exit code 2 (ENOENT): yum install -y git gcc make tar bzip2 readline-devel openssl-devel ruby-devel zlib-devel
spawn yum ENOENT
On now
rails new rails-app- Create a
now.jsonwith contents:
{
"version": 2,
"builds": [
{
"src": "rails-app/config.ru",
"use": "@now/ruby"
}
],
"routes": [{ "src": "/", "dest": "rails-app/config.ru" }]
}
- Now yields:
yarn info @now/build-utils@latest...
yarn info @now/ruby...
yarn add @now/[email protected]...
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @now/[email protected]
info All dependencies
└─ @now/[email protected]
Done in 0.56s.
yarn add @now/[email protected]...
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @now/[email protected]
info All dependencies
└─ @now/[email protected]
Done in 1.10s.
TypeError: util.getSystemErrorName is not a function
at getCode (/tmp/e97d8416e11caeb8/.build-utils/.builder/node_modules/@now/ruby/dist/index.js:28461:16)
at makeError (/tmp/e97d8416e11caeb8/.build-utils/.builder/node_modules/@now/ruby/dist/index.js:28500:35)
at handlePromise (/tmp/e97d8416e11caeb8/.build-utils/.builder/node_modules/@now/ruby/dist/index.js:3759:26)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
worker exited with code 20 and signal null
done
done
Deployment URL: rails-64wuh4wd8.now.sh
Any idea what this could be?
Hi @antonnyman
Ruby doesn't support now dev yet.
I'll add this as a feature request, thanks!
Update: I just realized the was an error in the now deployment. We will investigate the TypeError: util.getSystemErrorName is not a function, thanks
Hi @antonnyman
Upon further investigation, the error is likely due to Ruby 2.6 which adds additional features that are not available in Ruby 2.5.
Can you try deploying Rails with Ruby 2.5? Thanks!
https://zeit.co/docs/v2/advanced/builders#ruby-version
@antonnyman while this is in theory could work, we recommend you follow a different app structure. Try to make your frontend static, and use API functions written in Ruby.
Thanks @styfle and @rauchg !
I understand the way Rails generates a project might be a different direction for Now's purpose, I was just curious if it was possible since the docs mention Rails under advanced ruby usage. Also the tests for the ruby builder has a fixture for [Rails].(https://github.com/zeit/now/tree/canary/packages/now-ruby/test/fixtures/06-rails)
Maybe the docs could in the future specify which parts of Rails you can use, like the API parts?
Hi @antonnyman
It is possible to use Rails as you mentioned because we support Rack. The tests ensure that our Rack implementation works with known Ruby frameworks.
Rails is not recommended because, like many legacy web frameworks, it is not optimized for serverless. So you will certainly hit limitations such as 50MB max size, slow cold starts, maybe even slower builds.
Maybe the docs could in the future specify which parts of Rails you can use, like the API parts?
We recommend creating an api directory containing your functions. The platform will handle routing for you so you don't need an additional framework. Then add a index.html file in the root for your home page.
See the intro documentation here: https://zeit.co/docs/v2/serverless-functions/introduction
Thanks for the explanation @styfle.