Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view my environment variables?

Tags:

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.

like image 394
chopper draw lion4 Avatar asked Jul 10 '14 20:07

chopper draw lion4


People also ask

How do you see environment variables in Windows?

On WindowsSelect Start > All Programs > Accessories > Command Prompt. In the command window that opens, enter set. A list of all the environment variables that are set is displayed in the command window.

How do I get a list of environment variables?

You can open a Command Prompt, type set , and press Enter to display all current environment variables on your PC. You can open PowerShell, type Get-ChildItem Env: , and press Enter to display all current environment variables on your PC.

How do I find my environment variable PATH?

Select Start, select Control Panel. double click System, and select the Advanced tab. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it.

How do I view environment variables in Windows 11?

Setting Environment Variables in Windows 11Tap Win + I to access the Settings menu. Scroll to the bottom of the page and click “About.” Navigate to “Device Specifications” and press “Advanced System Settings.” In the “System Properties” dialogue box, hit “Environmental Variables.”


1 Answers

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.

like image 92
Todd A. Jacobs Avatar answered Sep 20 '22 03:09

Todd A. Jacobs