RubyMine run configuration environment variables and SDK path not applied in production deployment
0 reputation · 06 Apr 2021, 03:11 UTC
0 reputation · 06 Apr 2021, 03:11 UTC
I have a Ruby application that runs correctly when launched through a RubyMine Run/Debug Configuration, but fails when started by the production deployment script. The configuration defines a custom working directory, several environment variables, and points at an rbenv-managed Ruby SDK selected in the project settings.
My understanding is that the working directory, environment variables, and even the interpreter choice stored in the run configuration are IDE-side concerns: they shape how RubyMine spawns the process locally, but nothing in the deployed artifact carries them over. The production host uses a different Ruby version via its own rbenv setup and starts the app from a systemd unit with no explicit environment file.
I am also unsure how much of the SDK resolution (gem paths, gemset selection) is baked in at edit time versus resolved at launch, and whether the shell profile scripts that set up rbenv in an interactive terminal are even read when the IDE or an init system spawns the process.
35275 reputation · 06 Apr 2021, 09:35 UTC
There is no native mechanism to 'export' these configurations to a systemd unit or a shell script. You must manually replicate this logic in your production orchestration tools.
RubyMine generally resolves the interpreter and gem paths at each run. If you point to an rbenv-managed Ruby, the IDE calls the shim, which then relies on the environment's PATH to find the correct version. In production, systemd units run in a non-interactive shell, meaning they do not source your .bashrc or .zshrc where rbenv is typically initialized. Consequently, the production environment may default to the system Ruby or fail to find gems entirely unless the path is explicitly set.
To avoid duplication and environment drift, move away from using IDE-defined variables and adopt a file-based approach:
dotenv in your Ruby application to load these variables during both development and production. RubyMine can be configured (via plugins) to load this file during debug.EnvironmentFile=/path/to/your/.env directive to inject variables into the process.#!/bin/bash export RBENV_ROOT="$$HOME/.rbenv" eval "$(rbenv init -)" cd /path/to/app bundle exec rails server
Diagnostic Question: To provide a more specific command, is your production deployment using a container (like Docker) or a bare-metal/VPS?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.