Questions tagged [direnv]

An environment switcher for the shell to unclutter your .profile

direnv is an environment switcher for the shell. It knows how to hook into bash, zsh, tcsh, fish shell and elvish to load or unload environment variables depending on the current directory.

This allows project-specific environment variables without cluttering your ~/.profile (or ~/.bashrc/etc).

27 questions
83
votes
21 answers

How to automatically activate virtualenvs when cd'ing into a directory

I have a bunch of projects in my ~/Documents. I work almost exclusively in python, so these are basically all python projects. Each one, e.g. ~/Documents/foo has its own virtualenv, ~/Documents/foo/venv (they're always called venv). Whenever I…
Alex Lenail
  • 12,992
  • 10
  • 47
  • 79
38
votes
10 answers

How can I install GRPCIO on an Apple M1 Silicon laptop?

Every time I try to install a pip package with GRPCIO as a dependency inside a .direnv project I get a build failure due to my architecture being arm64. How can I work around this while waiting for the GRPCIO crew to release an update? Using…
reka18
  • 7,440
  • 5
  • 16
  • 37
17
votes
3 answers

docker-compose .env vs direnv .envrc

We've been using direnv for quite some time now to automatically load environment variables in a specific folder. And since version 3, docker-compose seems to support .env files. The .envrc files used by direnv use export: export…
Patrick
  • 7,903
  • 11
  • 52
  • 87
12
votes
3 answers

Direnv not loading environment when shell starts in a directory with .envrc

Imagine I am in a shell with the working directory set to a directory that contains an .envrc file. When I now open up a new tab in my terminal emulator, a new shell is launched into the same working directory as the original shell. For some reason,…
aef
  • 4,498
  • 7
  • 26
  • 44
7
votes
1 answer

Why am I no more able to change the environment variable $USERNAME on macOS?

WHAT I WANT TO DO $ echo $USERNAME myusername $ export USERNAME=newvalue $ echo $USERNAME newvalue WHAT IS HAPPENING $ echo $USERNAME myusername $ export USERNAME=newvalue $ echo $USERNAME myusername WHAT I TRIED I tried to use: sudo ...; I tried…
Riccardo Persiani
  • 702
  • 1
  • 5
  • 25
4
votes
2 answers

Direnv not allowing me to allow

I've installed direnv (v2.18.2) onto my Ubuntu 16.04 machine using: sudo snap install direnv as per the website, and added the line: eval "$(direnv hook bash)" to my ~/.bashrc file as per the instructions. When I navigate into the directory with my…
LomaxOnTheRun
  • 592
  • 1
  • 8
  • 21
4
votes
1 answer

Unable to override PS1 with direnv

I am following the direnv wiki on PS1. I have the following relevant entries in my files. .bashrc DEFAULT_PS1='\[$(ppwd)\]\u@\h:\w$(__git_ps1 " (%s)")' # add some more things to DEFAULT_PS1, conditionally DEFAULT_PS1+='>…
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
4
votes
2 answers

activating virtualenv with direnv doesn't activate virtualenv

I'm using direnv to source my virtualenv when I change into the directory. /project .envrc /env <--- my virtualenv .envrc source env/bin/activate When I change directory into /project I get the output: direnv: loading .envrc direnv: export…
Ephapox
  • 757
  • 1
  • 8
  • 18
3
votes
1 answer

How to use direnv with python venv?

I have this line in my .envrc source python3-venv/bin/activate I basically created a python3 venv inside the folder where the .envrc is located. However even through the .evnrc is executed (e.g. all now env variables are set correctly when I enter…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
3
votes
1 answer

How to autoload environment variables specific to one file path?

I am working on developing a solution that simplifies hands-on debugging of failed Jenkins builds. This involves SSH-ing to the right Jenkins node and going directly on the WORKSPACE so you can interactively try different changes that could solve…
sorin
  • 161,544
  • 178
  • 535
  • 806
2
votes
0 answers

Can not get asdf-direnv work in docker when building

I'm trying to use asdf-direnv in docker. Following the README of asdf-direnv, I make this Dockerfile FROM nvidia/cuda:10.2-devel-ubuntu18.04 RUN chsh -s /bin/bash SHELL ["/bin/bash", "-ic", "-l"] ENV DEBIAN_FRONTEND=noninteractive RUN apt-get…
Saddle Point
  • 3,074
  • 4
  • 23
  • 33
2
votes
1 answer

Why is direnv failing to read my zsh/fish/elvish/tcsh script?

When attempting to evaluate a .envrc file I get the error "emulate: command not found" or "cd: -q: invalid option" or any number of various possible errors in my completely valid zsh/fish/elivsh/tcsh script.
OmnipotentEntity
  • 16,531
  • 6
  • 62
  • 96
2
votes
1 answer

gcloud: is it possible to change the default project based on the current folder?

I'm working on several gcloud projects and I'm tired of having to type out --project XYZ every time I need to call a command, or worse having the command execute on the wrong project if I forget to add that in.
1
vote
0 answers

understand linux shell hooks as used by direnv

I would very much like to understand how Linux shell hooks work... (bash in particular) Could any one point me to the right documentation or explain the main idea behind this concept? I've looked into the direnv documentation that states the…
mishoo78
  • 85
  • 2
  • 7
1
vote
1 answer

asdf errors when starting Linux shell

Sorry it's hard to be specific here but I'm struggling to pin down the source of various error messages in my Linux shell with asdf. I've got Fish shell 3.4.0 running on a RHEL 8.5 GNU/Linux system, and have installed and used asdf with it for…
hpy
  • 1,989
  • 7
  • 26
  • 56
1
2