Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: Rails build fails when configured as an api #751

Closed
1 task done
taphill opened this issue Jan 4, 2023 · 2 comments · Fixed by #839
Closed
1 task done

Ruby: Rails build fails when configured as an api #751

taphill opened this issue Jan 4, 2023 · 2 comments · Fixed by #839
Labels
bug Something isn't working

Comments

@taphill
Copy link

taphill commented Jan 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I ran into a build failure when attempting to deploy a new Rails API to Railway using the railway up command.

It appears that the build fails when it tries to run this rake task assets:precompile

Screen Shot 2023-01-03 at 7 10 01 PM

This is because when you create a rails project with the --api flag it skips all the views, assets, etc. as outlined in the Rails docs here, so the assets:precompile task does not exist.

I think this is the function that probably needs to be updated

It looks like you're looking within the config/application.rb file. Perhaps you can add some logic to look for the config.api_only = true line and adjust the build settings based on that.

Screen Shot 2023-01-03 at 7 18 54 PM

To reproduce

  1. In the Railway dashboard, create a new empty project
  2. On your local machine, create a new rails API with a postgres db rails new my_api --api --database=postgresql
  3. Create and migrate the db rails db:{create,migrate}
  4. Back in the Railway dashboard click the button at the bottom to set up your project locally
  5. Copy the Railway link to connect to the Railway project and paste it into your terminal
  6. Run railway up

Expected behavior

I would expect the build to succeed.

Environment

MacOS 12.3.1
ruby 3.2.0
rails 7.0.4

Screen Shot 2023-01-03 at 11 02 01 PM

@taphill taphill added the bug Something isn't working label Jan 4, 2023
@taphill
Copy link
Author

taphill commented Jan 4, 2023

I've not ever used Rust before and don't know how complicated this would be to fix, but I'd be happy to try and submit a PR if this is a rails feature you want to support.

@fusion2004
Copy link

I think you can fix this in a nixpacks.toml config file:

[phases.build]
cmds = [] # remove this to re-enable asset building

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants