Ruby on rails KeyError environment variable - ruby-on-rails

I experience an error : 'fetch': key not found: "APPLICATION_HOST" (KeyError)'
This errors occurres since I tried to implement a new gem that requires dotenv gem. That produced a lot of tries to fix. I revert my code to a stable one but I still cannot run my app supposed related to my machine configuration.
For now none of my environment variables in my .env file can be read by the app.
A teammate has the same code as mine and hasn't any config in his ~/.bashrc neither in ~/.bash_profileand our .env file has chown readable states.
Last information we use a gemset for this project.
Thanks by advance for any help

I solved the problem by cloning the repo in another folder and the project runs again!

Related

Deploying Ruby on Rails apps to Railway

I hope you are all well!
For several days now I have been trying to deploy a simple rails app to Railway.app, and failing catastrophically and repeatedly to get it to run.
Here is the github repo:
https://github.com/CaffieneSage/blogApp-rails-
The error I am getting is during the deploy step specifically:
bundler: not executable: bin/rails
I have successfully deployed apps to heroku in the past. I suspect there is something simple that I am missing. I have tried rerolling and deploying the default rails app to simplify things. I have made sure to us postgres instead of SQLite3 as the db. I have spun up an instance of postgres on railway and tried to set my environment variables to point to it. I have had a go within the CLI as well.
Thanks in advance for any advice you may have to offer!
This is my first post on stack overflow, please go easy on me ;]
The issue likely stems from the script bin/rails not having the executable bit on the file.
You can see the file permissions using ls:
ls -l bin/
All of the files will display:
-rw-r—r—
These need to have the executable bit set, so you can run something like:
chmod +x bin/*
After which all the files should have this permission set:
-rwxr-xr-x
Don’t forget to commit the changes.
Read more on file permissions: https://en.wikipedia.org/wiki/File-system_permissions

Missing encryption key to decrypt file with: Rails Development environment

I've been working on a rails app & I'm sharing the code with someone through github. When I run the code locally on my machine, everything works fine, but when they run the code on their local environment they get this error:
Missing encryption key to decrypt file with. Ask your team for your master key and write it to /Users/krys2fa/articles/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
Does anyone know how I can fix this?? Thank you :)
Tell your buddy to run:
EDITOR="nano" rails credentials:edit
This command will open the nano editor and will let create your credentials file. Once then tell him to restart his server.
Remember to not to include this file in the version system. By default it is ignored in the .git file, so it is very likely your partner does not have it.
It is very weird that you can run it but your partner doesn't. Are you sure he is not requiring the master key file in development.rb ?

Following tutorial for installing Ruby on Rails for Heroku. Currently stuck

very new to all this. I am following a tutorial to get Heroku running through ruby on rails.
I have Microsoft Windows so I am currently following Heroku's official tutorial and am stuck here
I installed PostgresSQL 10.1 using windows installer x86-64 and have noted my login information for Postgres.
However, I do not understand this part:
Remember to update your PATH environment variable to add the bin
directory of your Postgres installation. The directory will be similar
to this: C:\Program Files\PostgreSQL\<VERSION>\bin. If you forget to
update your PATH, commands like heroku pg:psql won’t work.
The closest thing I could find to an explanation and tutorial was this Java site.
I went inside Enviromental Variables and set the system path to: C:\Program Files\PostgreSQL\10\bin
However, when I tried testing it out by typing in heroku pg:psql, it said no app specified so I'm unsure if I did it correctly or not.
Also, the next tutorial step is:
Open the config\database.yml file and set the username and password
for your local (development) database. Look for these line:
I searched and I have no such file on my computers. Needless to say, I'm stumped. Any assistance to progress through the tutorial is appreciated. Thank you.
regarding your first error, the problem is that you are not specifying for which app you want to open the database cli (psql). Hopefully, the solution is easy:
heroku pg:psql --app app_name
# or
heroku pg:psql -a app_name
About the second question, the tutorial assumes that you have already created an application.
If you go to the root path of your project, you will find some subfolders such as app, config, db, lib, public, tmp, vendor.. Here you will find config\database.yml.

Ruby on Rails | AirBrake Error

Trying to run a project that was provided by a client.
I have the correct versions of Ruby, Gems, Rails, Bundler, Homebrew etc installed.
When I run rails server I get the following error in terminal.
.rvm/gems/ruby-2.2.2/gems/airbrake-ruby-1.0.4/lib/airbrake-ruby.rb:288:in `call_notifier': the 'default' notifier isn't configured (Airbrake::Error)
After much time spent on Google I couldn't find a fix on this.
Here is a screenshot of the whole terminal error message which I get the feeling these other lines could be related.
It looks like a previous developer may have hardcoded a commit hook in the application, pointing to a file in their local .git folder (and which you don't have).
I'd recommend either asking the developer to provide the missing file, create a dummy file in the same place, or removing that line.

Rails 4.0 receiving emails - no such file (runner)

Up until now I've been using script/runner to forward bouncebacks to eblast-bounceback#mydomain.com and eblast-bounceback#dev.mydomain.com. However it is no longer working in Rails 4.0. I also can't seem to find a good resource online to illustrate how to do it. I usually get directed to the 'whenever' gem - but that's for cron jobs, not for 'piping to programs'.
So this is essentially what I'm currently doing, but is failing:
|/home/user/rails/dev.www/script/rails runner 'EBlast.receive(STDIN.read)' -e development
How do I get this to work? I'm not on Rails 4.1, I'm on 4.0. FWIW I do not have bin/rails. The above command yields "no such file or directory".
There were actually a few things I needed to do.
The email eblast-bounce#dev.mydomain.com was considered 'unroutable'. At first I figured it was because there wasn't any MX records for the subdomain, so I added one. But then I still got the error. I had manually updated the aliases file in /etc/valiases to pipe to the program using a symlinked directory (because I was deploying with Capistrano, and the directory ends up changing after every deploy). Turns out symlinks don't work for some reason when it comes to exim routing (/home/me/rails_deployments/dev.www/current/bin/rails fails). Maybe I'm wrong about the symlinks thing but the problem went away when I used the solution below.
This problem however was solved when I eventually came to another problem (/usr/bin/env: ruby: No such file or directory). I'm using RVM to manage rubies/gems, and apparently the email forwarder didn't know what ruby was. This leads to the final solution:
(when in cPanel, "pipe to program" assumes the user home directory (/home/me/))
.rvm/wrappers/ruby-2.1.0#website/ruby /home/me/rails_deployments/dev.www/current/bin/rails runner 'EBlast.receive(STDIN.read)' -e development
Where ruby-2.1.0 is my current ruby version, and #website is the gemset used by the EBlast.receive code base.
EDIT: Spoke too soon, the command has its own set of problems...(gemfile not present). This is ludicrous.

Resources