PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How do I view my environment variables?

 August 22, 2022     bash, environment-variables, ruby-on-rails, terminal     No comments   

Issue

I am trying to connect to my pusher server but am receiving the error:

Missing client configuration: please check that key, secret and app_id are configured.

I want to check my environmental variables, but cannot find any clear way to do this on Stack Overflow yet.


Solution

Printing the Environment from the Shell

As other answers have pointed out, one can use /usr/bin/env or /usr/bin/printenv from the command line to see what the environment is in the shell before starting Rails, or in a subshell after starting it. For example:

  1. rails s RETURN
  2. CTRL-Z
  3. env RETURN
  4. fg RETURN

Displaying ENV from the View Layer

In Ruby, ENV is a "hash-like" accessor for environment variables; it is not actually a Hash. You can introspect ENV from your Rails console easily enough simply by typing ENV or ENV['foo'], but sometimes you may want to see what Rails thinks the environment is during rendering. In that case, you want the Rails debug helper. For example:

# ERB
<%= debug ENV.to_h.to_yaml %>

# HAML
= debug ENV.to_h.to_yaml

Calling #to_yaml to serialize the ENV object will make the output easier to read, but requires you to convert ENV to a hash or array first. You can also just invoke debug ENV without chaining; it's just harder on the eyes.



Answered By - Todd A. Jacobs
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing