This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

I can't verify “SECRET_KEY_BASE” is properly set in Linux with $ printenv | grep SECRET_KEY_BASE.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My ruby ​​version is 2.6.6, my mysql version is 8.0.23, my mysql2 version is 0.5.3, my bundler version is 2.2.21, my rails version is 5.0.7.2, and my Xcode version is 12.5.

I use macOS Big Sur(version 11.4) and the text editor "Atom".

I'm planning to release my Rails application with the URL of HEROKU(example. https://[My APP Name].herokuapp.com).

I ran the following command.


The following error occured.


I set two environment variables as below with this command: $ heroku config:set [ENVIRONMENT VARIABLE NAME].


I ran the following command.


I ran the following command to get GENERATED_CODE.


I ran the following command.


I set the environment variable "SECRET_KEY_BASE" as below in Vim editor.


I saved the above SECRET_KEY_BASE and ended Vim editor with the two below commands.


I opened the vim editor again as below with this command:$ vi /etc/profile.


I ran the two following command for verifying that the environment variable SECRET_KEY_BASE is properly set in Linux.


But I can't verify that the environment variable SECRET_KEY_BASE is properly set in Linux with this command:
or with:

Would you like to tell me the reason why I can't verify that the environment variable SECRET_KEY_BASE is properly set in Linux with the two following command?
 
Saloon Keeper
Posts: 24339
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you do an "echo" on an environment variable and nothing displays, that means that the variable wasn't set for your local environment.

First, do you REALLY want that variable set for ALL users? Or just the user that Heroku is going to run as. Generally "secret" and global don't go together. In which case, consider using one of the account profile directories.

Secondly, iy you DO want it global, check to see if there's an /etc/profile.d directory. If so, add a file there instead of modifying /etc/profile. You'll be less likely to lose things when the OS gets updated.

Last, but not least, you appear to be adding the command like this:


That's wrong. The "$" is what the shell prints as a prompt for ordinary users, not something you type in yourself. The correct line would either be:
Or

The second version is safer, because while BASH allows both commands on a single line, some of the other shells do not.
 
Harukaze Miyabi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What's the way to check to see if there're an /etc/profile.d directory and an /etc/profile file ?

if there're not an /etc/profile.d directory and /etc/profile file,  should I make by myself an /etc/profile.d directory and an /etc/profile file by running the below commands in the terminal of Atom ?
 
Marshal
Posts: 22461
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harukaze Miyabi wrote:What's the way to check to see if there're an /etc/profile.d directory and an /etc/profile file ?



There are people who use a shorter form:

This has some drawbacks though:
  • If you want to execute more than one command if the directory exists, you need to combine them all with && or in some other way.
  • If the directory does note exist, the command is skipped but the overall result (as seen by $?) still indicates a failure. It could cause the entire script to fail (and depending on the script even abort early)
  •  
    Tim Holloway
    Saloon Keeper
    Posts: 24339
    167
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You should not attempt to create either /etc/profile or /etc/profile.d. If the OS supports them, then the OS system install will have created them. Otherwise you would have to set up a whole lot of other infrastructure and possibly compile your own custom shell to get them to be found and used.

    To use /etc/profile.d, create a file named something like "99-set-secret-key.sh" and put your directives in it. or add them to /etc/profile.d/sh.local if that file exists.

    The way it all works on my system is that /etc/profile is a script that executes a loop over the files in /etc/profiles.d and runs ("sources") each file whose extension ends with ".sh", then executes /etc/profile.d/sh.local.

    Due to the way Unix works, the profiles will be executed in alphabetical order of their filename.
     
    Harukaze Miyabi
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't know the way to check to see if there're an /etc/profile.d directory and an /etc/profile file,

    so I wrote the following command in the Vim editor with this command $ vi /etc/profile.


    I can't verify that the environment variable SECRET_KEY_BASE is properly set in Linux with the below commands.


    Would you like to tell me the reason why I can't verify that the environment variable SECRET_KEY_BASE is properly set in Linux with the two above commands?
     
    Tim Holloway
    Saloon Keeper
    Posts: 24339
    167
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Harukaze Miyabi wrote:I don't know the way to check to see if there're an /etc/profile.d directory and an /etc/profile file



    I don't know why you find that difficult. Just do:


    That will tell you if it exists, what its access rights are and how big it is. If nothing prints you don't have one.

    And if you don't have one, adding one probably won't do any good. And if you did have one, you may have just broken a critical part of MacOS.

    I (we?) are giving advice based on Linux. But Linux is NOT MacOS. MacOS is a variant of Mach/BSD Unix. Although they are a lot alike, they are not identical. So don't think our advice is infallible.

    I did a quick web search for the bash shell man page and it does say that profiles should be found by default in  system-wide startup file /etc/profile  or  personal  initialization  files  ~/.bash_profile,
    ~/.bash_login, or ~/.profile.

    However, too many source on the Internet don't carry date/version information so I could be reading an obsolete description.

    Also, I've been under the impression that you are, in fact, using the bash shell. You could be using csh, the Korn shell, or any of several other shells, including one that Apple themselves created. In which case profile configuration might be different.
    reply
      Bookmark Topic Watch Topic
    • New Topic