# How to get into the Rails console, or other tasks in a buildpack-based deploy

**URL:** <https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642>\
**Category:** Questions / Help\
**Tags:** rails, login-only\
**Created:** [January 9, 2022, 8:45pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642 "2022-01-09T20:45:47Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [June 21, 2022, 3:33am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/21 "2022-06-21T03:33:58Z")

</div>

I’m using pretty standard buildpacks:

```nohighlight
[build]
  builder = "heroku/buildpacks:20"
  buildpacks = ["heroku/nodejs", "heroku/ruby"]

```

---

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [June 21, 2022, 7:01pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/22 "2022-06-21T19:01:20Z")

</div>

So I was able to get this working by:

```auto
fly ssh console
bash
cd /app
cat profile.d/ruby.sh # executing is denied

```

Exporting the variables found there manually sets up what we need. Then we can do `bin/rails c` and the console loads.

---

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [June 23, 2022, 2:43am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/23 "2022-06-23T02:43:37Z")

</div>

Update: My solution no longer works as now `/app/profile.d` no longer exists. For a few minutes on one deploy (currently working through [another issue](https://community.fly.io/t/secrets-revert-to-old-values-on-deploy/5707/4)) `/cnb/process` existed but then disappeared when deploying again.

---

<div class="post-metadata">

**Author:** ![kevbuh](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kevbuh](https://community.fly.io/u/kevbuh)\
**Post date:** [July 14, 2022, 5:46am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/24 "2022-07-14T05:46:52Z")

</div>

I was able to get it working by doing:

```auto
fly ssh console
bash
cd /app
bin/rails c

```

Hope this helps someone.

---

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [July 18, 2022, 11:15pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/25 "2022-07-18T23:15:19Z")

</div>

Once I cleared up (admittedly many) other issues this seemed to go away, so I don’t have the solution as everything I did wasn’t related to this issue.

---

<div class="post-metadata">

**Author:** ![lortza](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/lortza/32/5615_2.png) [@lortza](https://community.fly.io/u/lortza)\
**Post date:** [October 19, 2022, 3:47pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/26 "2022-10-19T15:47:43Z")

</div>

This was the most succinct way of getting into `rails console` that I have found so far:

```auto
fly ssh console -C "/app/bin/rails console"

```

---

<div class="post-metadata">

**Author:** ![fgallaire](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/fgallaire/32/8083_2.png) [@fgallaire](https://community.fly.io/u/fgallaire)\
**Post date:** [January 2, 2023, 12:08am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/27 "2023-01-02T00:08:51Z")

</div>

How do you install the apt buildpack ?

---

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [May 26, 2023, 8:47pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/28 "2023-05-26T20:47:35Z")

</div>

This issue is cropping up again for me. The furthest I can get is:

1. `fly ssh console`
2. `bash`
3. `cd /app`
4. `bin/rails c`

Then I get an error about Ruby versions:

```plaintext
Your Ruby version is 2.7.0, but your Gemfile specified 3.2.2

```

I’ve got no idea where Ruby 2.7.0 comes from, `.ruby-version` is 3.2.2 — I haven’t used Ruby 2 in probably years now.

---

<div class="post-metadata">

**Author:** ![rubys](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rubys/32/16907_2.png) [@rubys](https://community.fly.io/u/rubys)\
**Post date:** [May 26, 2023, 9:08pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/29 "2023-05-26T21:08:52Z")

</div>

Does your Dockerfile have a line that looks like:

```auto
ARG RUBY_VERSION=2.7.0

```

If you have not been making changes to your Dockerfile, you can regenerate it using:

```auto
bin/rails generate dockerfile

```

If you run this command, you will get the ability to review the changes before accepting them. If you need to install the generator, you can follow [these instructions](https://github.com/fly-apps/dockerfile-rails#usage).

---

<div class="post-metadata">

**Author:** ![brody-next-tms](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@brody-next-tms](https://community.fly.io/u/brody-next-tms)\
**Post date:** [May 26, 2023, 9:19pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/30 "2023-05-26T21:19:46Z")

</div>

Hello @rubys, I’m using a buildpack so I don’t have a `Dockerfile`.

---

<div class="post-metadata">

**Author:** ![rubys](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rubys/32/16907_2.png) [@rubys](https://community.fly.io/u/rubys)\
**Post date:** [May 26, 2023, 9:28pm UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/31 "2023-05-26T21:28:58Z")

</div>

In that case, the 2.7.0 is likely coming from the buildpack. I’d encourage you to try a Dockerfile using the instructions from the link above.

---

<div class="post-metadata">

**Author:** ![catflydotio](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/catflydotio/32/14559_2.png) [@catflydotio](https://community.fly.io/u/catflydotio)\
**Post date:** [April 27, 2024, 12:43am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/32 "2024-04-27T00:43:28Z")

</div>

Category updated on April 27, 2024, 12:43am UTC

From #How To to #Questions / Help

---

<div class="post-metadata">

**Author:** ![catflydotio](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/catflydotio/32/14559_2.png) [@catflydotio](https://community.fly.io/u/catflydotio)\
**Post date:** [April 27, 2024, 12:43am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/33 "2024-04-27T00:43:29Z")

</div>

Tags updated on April 27, 2024, 12:43am UTC

Added #rails

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [May 4, 2024, 12:43am UTC](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642/34 "2024-05-04T00:43:43Z")

</div>

Closed on May 4, 2024, 12:43am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

[Previous page](https://community.fly.io/t/how-to-get-into-the-rails-console-or-other-tasks-in-a-buildpack-based-deploy/3642.md?page=1)
