-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding Invoke-Command "$(direnv hook pwsh)" to $PROFILE doesn't seem to work #1207
Comments
I'm currently messing around with powershell as well. If I had to guess, that LocationChangedEventArgs only works in powershell version 7.2 and above https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.locationchangedeventargs?view=powershellsdk-7.3.0 When you are using windows terminal, you have to manually set powershell 7.x to the default otherwise it drops down to 5.x. https://www.tenforums.com/tutorials/177955-how-change-default-profile-windows-terminal-app-windows-10-a.html The DIRENV_CONFIG env var isn't registered for me, so I guess I have to insert that into the $PROFILE as well. Did scoop install that for you? Update, turns out the XDG directories are required because the $env:HOME variable is not set on windows, the $HOME variable is set, but they are not the same thing. Code for finding default directories is here https://github.com/direnv/direnv/blob/master/xdg/xdg.go . I would assume something like os.UserHomeDir would be a better default. Using this $PROFILE script I was able to get direnv to recognize the .envrc. I noticed it has to be a .envrc, I need to check why .env isn't working. Edit: this appears to be due to the missing direnv.toml https://direnv.net/man/direnv.toml.1.html#codeloaddotenvcode $env:XDG_CACHE_HOME=(Join-Path $HOME .cache)
$env:XDG_DATA_HOME=(Join-Path $HOME .local share)
$env:XDG_CONFIG_HOME=(Join-Path $HOME .config)
if(-not(Test-Path $env:XDG_CACHE_HOME)){
mkdir $env:XDG_CACHE_HOME
}
if(-not(Test-Path $env:XDG_DATA_HOME)){
mkdir $env:XDG_DATA_HOME
}
if(-not(Test-Path $env:XDG_CONFIG_HOME)){
mkdir $env:XDG_DATA_HOME
}
Invoke-Expression "$(direnv hook pwsh)" Here is the output from $PSVersionTable $PSVERSIONTABLE
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0 Now I'm getting an error (with redaction)
cd direnvtest
/bin/bash: "{{REDACTED}}/scoop/apps/direnv/current/direnv.exe": No such file or directory
/bin/bash: __main__: command not found
direnv: error exit status 127 I did scoop bucket add main
scoop install main/direnv This appears to be direnv calling through bash and using a windows path in WSL for the executable? |
perfect, that was it @patrickhuber getting this now, but i'll have to assess later. this can be closed. here's a really garbage scoop manifest for powershell 7.4.0 {
"##": "This file is a template. Fill the blanks and add or remove fields as necessary.",
"version": "7.4.0",
"description": "Ideally, the latest version of Windows Powershell",
"homepage": "https://github.com/PowerShell/PowerShell",
"license": "MIT",
"notes": "https://github.com/PowerShell/PowerShell/releases/tag/v7.4.0",
"architecture": {
"64bit": {
"url": "https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/PowerShell-7.4.0-win-x64.zip",
"hash": "62151DB1D98A8B56AEB249CC8A3CE17948F1C83B4062DAC8D0C4302DE71CBD75"
}
},
"bin": "pwsh.exe"
} you might have to run the powershell that comes with your OS and run also the $PROFILE location is different for this version compared to mine. PowerShell 7.4.0 |
Describe the bug
I'm not entirely sure if this is a bug or if it just me not understanding powershell
.envrc
syntax.It occurs regardless of project directory, so i'm assuming it's just out of date powershell version at the moment.
Any help is appreciated. Also the powershell documentation could really use some love imho. But I'm willing to be humbled and told that I missed some obvious documentation file.
Furthermore I'm looking for advice on how to set up a project so that the .envrc sets up the env correctly on all OSes; linux, windows, macOS, and freeBSD.
Regardless, thank you all for your hard work. This project is awesome.
To Reproduce
install scoop, then install direnv via
This also happens when compiling from source, as I had to in order to get the pwsh hook to be available. (technically direnv v2.32.0 though)
add Invoke-Command "$(direnv hook pwsh)" to $PROFILE
re-open powershell or windows-terminal
Expected behavior
direnv doesn't produce an error when the shell starts, and a simple environment variable
TEST_VAR
to be loaded when reloading the project directory, set to a value of "hello world!".Environment
windows-terminal: 1.18.3181.0
bash_path: C:\ProgramData\scoop\shims\bash.exe
powershell:
Additional context
this happens when i open powershell or windows-terminal
The text was updated successfully, but these errors were encountered: