I do not quite get the difference between direnv and Shadowenv

This issue has been created since 2019-09-10.

Sorry for asking there, but I couldn't find any other discussion channel.


In README there is fragment:

Unlike other tools like direnv, this has the interesting property of allowing us to do things like simulate chruby reset upon entry into a directory without the user having chruby installed (and undo these changes to the environment when cd'ing back out)

But it is still possible in direnv via layout function. So is there anything more except different configuration language (sh vs Ketos)?

burke wrote this answer on 2019-09-10

Yup, direnv is basically capable of everything Shadowenv is capable of; the main difference is that shadowenv can't do anything other than set environment variables with a bit of conditional logic, and has strict execution resource restrictions, so I feel comfortable running it in shell hooks and other synchronous operations. It can never run for longer than (IIRC) 100ms.

fzakaria wrote this answer on 2020-07-10

It would be neat to offer some precanned shadowlips files or examples similar to direnv (https://direnv.net/docs/ruby.html)
It's not clear from the docs how to use shadowlisp to maybe accomplish some simple tasks.

At shopify, is it used just to purge the current environment and then rely on Nix to actually choose the Ruby version?
(nix-shell)

lugray wrote this answer on 2020-07-13

It would be neat to offer some precanned shadowlips files or examples similar to direnv (https://direnv.net/docs/ruby.html)
It's not clear from the docs how to use shadowlisp to maybe accomplish some simple tasks.

There's a ruby example in the README - what are you seeking to accomplish that that fails to give a launching point for?

At shopify, is it used just to purge the current environment and then rely on Nix to actually choose the Ruby version?
(nix-shell)

No, we don't use nix shell. We make full use of shadowenv to add the right nix paths to the environment for whichever standard shell (bash, zsh, or fish) the user prefers.

fzakaria wrote this answer on 2020-07-13
lugray wrote this answer on 2020-07-13

The example in the README only removes environment variables for Ruby.

You are correct - I scanned that too quickly and missed that it was entirely destructive. I've added #74.

lugray wrote this answer on 2020-07-13

Because you mentioned nix, @fzakaria, a Shadowlisp for ruby from a project using it:

(provide "ruby" "2.7.1")

(let ((dev-env "/nix/store/9b7ff3xkcdmqgszxg306z5rvysxn5g4q-shadowenv-ruby-env-shopify"))
  (do
    (env/set "DEV_PROFILE" dev-env)
    (env/prepend-to-pathlist "PATH"    (path-concat dev-env "bin"))
    (env/prepend-to-pathlist "PKG_CONFIG_PATH" (path-concat dev-env "lib" "pkgconfig"))
    (env/prepend-to-pathlist "MANPATH" (path-concat dev-env "share" "man"))))

(when-let ((ruby-root (env/get "RUBY_ROOT")))
 (env/remove-from-pathlist "PATH" (path-concat ruby-root "bin"))
 (when-let ((gem-root (env/get "GEM_ROOT")))
   (env/remove-from-pathlist "PATH" (path-concat gem-root "bin")))
 (when-let ((gem-home (env/get "GEM_HOME")))
   (env/remove-from-pathlist "PATH" (path-concat gem-home "bin"))))
(env/set "GEM_PATH" ())
(env/set "GEM_HOME" ())
(env/set "RUBYOPT" ())
(env/set "RUBYLIB" ())

; generated from /nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/nix-support/setup-hook
(env/prepend-to-pathlist "GEM_PATH" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/lib/ruby/gems/2.7.0")
(env/prepend-to-pathlist "RUBYLIB" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/lib/ruby/site_ruby")
(env/prepend-to-pathlist "RUBYLIB" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/lib/ruby/site_ruby/2.7.0")
(env/prepend-to-pathlist "RUBYLIB" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/lib/ruby/site_ruby/2.7.0/x86_64-darwin")

; generated from /nix/store/gvywl8dyps5qiinybby6jqp2lwkkxdc3-bundler-2.1.4/nix-support/setup-hook
(env/prepend-to-pathlist "GEM_PATH" "/nix/store/gvywl8dyps5qiinybby6jqp2lwkkxdc3-bundler-2.1.4/lib/ruby/gems/2.7.0")
(env/prepend-to-pathlist "RUBYLIB" "/nix/store/gvywl8dyps5qiinybby6jqp2lwkkxdc3-bundler-2.1.4/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib")

; generated from /nix/store/d89clwn24y83nzkksrjbhz4l2j9q71zn-gem-bundle-shopify/nix-support/setup-hook
(env/prepend-to-pathlist "GEM_PATH" "/nix/store/d89clwn24y83nzkksrjbhz4l2j9q71zn-gem-bundle-shopify/lib/ruby/gems/2.7.0")
(env/set "BUNDLE_PATH" "/nix/store/d89clwn24y83nzkksrjbhz4l2j9q71zn-gem-bundle-shopify/lib/ruby/gems/2.7.0")
(env/set "RUBYOPT" "-r /nix/store/6yl04bbvfwckvbl3rmnjzp1zzxlr0dk5-nix_store_safeguard.rb")

; some extra ruby activation niceties
(env/set "RUBY_ROOT" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1")
(env/set "RUBY_ENGINE" "ruby")
(env/set "RUBY_VERSION" "2.7.1")
(env/set "GEM_ROOT" "/nix/store/pm9vzwm9n5xp6zbxaaz6h1pd2fggp0nc-ruby-2.7.1/lib/ruby/gems/2.7.0")
(let ((gem-home "/Users/lisaugray/src/github.com/Shopify/shopify/.dev/gems/2.7.0"))
  (do
    (env/set "GEM_HOME" gem-home)
    (env/prepend-to-pathlist "GEM_PATH" gem-home)
    (env/prepend-to-pathlist "PATH" (path-concat gem-home "bin"))))
fzakaria wrote this answer on 2020-07-13

@lugray thanks -- I know my comment was a bit curt; I was responding via phone + email.

Thank you for the pull request;
I highly recommend maybe a recipes folder with some nice examples: ruby, nix+ruby, python etc.. :)

I know the documentation says that "tooling should generate" but for many simple projects I don't see why the files cannot be copied + committed into the repository.

I do see why potentially for nix since the hash may change.
What's setting the dependency on the nixpkgs though so they are within the store + not garbage collected ?

lugray wrote this answer on 2020-07-13

What's setting the dependency on the nixpkgs though so they are within the store + not garbage collected ?

That would be the tooling that's generating the Shadowlisp. For us, that's dev, an internal tool that sets up project dependencies and gets it ready to run. It sets up a gcroot via the project directory, so that it becomes broken if the project is deleted.

donk-shopify wrote this answer on 2021-08-19

No activity in a year

More Details About Repo
Owner Name Shopify
Repo Name shadowenv
Full Name Shopify/shadowenv
Language Rust
Created Date 2019-01-03
Updated Date 2022-09-22
Star Count 278
Watcher Count 364
Fork Count 11
Issue Count 13

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
klee fails with glibc 2.33 5 2021-02-18 2022-07-29
Z3 assertion fails with grep: "Evaluated expression has wrong sort" 0 2021-03-20 2022-08-18
KLEE package for Ubuntu and other Linux distros 15 2021-03-15 2022-08-18
instruction select doesn't explore the path 2 2021-03-21 2022-08-01
[question] Symbolizing a struct with a std::string and a std::vector 2 2021-03-15 2022-08-18
[Bug] Bug Here 'All tokens provided were invalid' 2 2022-05-10 2022-09-13
[HELP] My token changes evertyime so i can't set sniper 6 2022-05-18 2022-09-13
PrismaSelect : Subscription Question : How to deal with mismatched payload shape 13 2021-05-17 2022-08-23
[ckks][bootstrapping]: the scaling constant of the encoding matrices is not taken into account and replaced when the creating the bootstrapper 0 2022-08-15 2022-09-13
iOS get wrong Location 3 2021-03-05 2022-09-15
Suggestion: More adaptable replication config 1 2021-02-07 2022-09-24
Show location of `>>>` / `/deep/` in the `...combinators have been deprecated` message 0 2022-08-03 2022-09-01
onion like domain with ed25519 5 2022-07-29 2022-08-12
Fix hard-coded paths in SIBCASA template files 1 2021-10-18 2022-05-28
Help with some terms and better documentation 0 2021-02-08 2022-07-12
Making native builds bulletproof 6 2020-04-03 2022-09-01
Ocean Renderer creates visual tears if the scale is not uniform along all axes 1 2022-05-25 2022-09-02
Error after installing 2 2021-07-07 2022-09-23
Pacman errors when using archinstall 2 2022-01-31 2022-08-16
browser gets stuck while calling "html2canvas(element).then(function (canvas)" 2 2021-11-03 2022-09-25
alidns sign is wrong 阿里云 无法更新 签名错误 1 2022-09-11 2022-09-19
DDNS-GO无法获取到接口返回的IPV6地址,如何解决? 4 2022-08-20 2022-09-19
部署后,可以获取ip,但是提示获取失败。无法识别ip 2 2022-08-29 2022-09-19
This is not an issue , its a question 1 2018-11-01 2022-09-14
When initializing a new validator the `--key` option doesn't work 0 2022-02-07 2022-08-02
Fix WebSockets in `proxy` package 11 2020-09-27 2022-09-15
Camera resource is not being disposed/released after use 6 2022-07-07 2022-09-14
Rate-limiting daemon 0 2021-04-19 2022-08-22
Issue with `doctrine/persistence` v3 5 2022-04-29 2022-09-07
Azure Function CosmosDB output binding support for partial updates 2 2022-07-13 2022-09-21
Allow shift+enter to insert new line in commit message 4 2022-01-27 2022-08-22
White lines around blocks 1 2021-05-23 2022-09-24
improve std.sort.sortContext to use block sort implementation 2 2022-03-10 2022-09-10
Bug - React section - Hooks: Broken link in Additional Resources 4 2022-02-24 2022-09-18
ibm.power_aix.suma - TypeError: '>' not supported between instances of 'NoneType' and 'str' 0 2022-04-11 2022-09-12
It doesn't work at all 1 2017-02-07 2022-09-15
Fix broken links and update api proxy config 0 2021-05-25 2022-09-23
image reading from s3 is broken with dask_image.imread in current pip / conda build 8 2021-05-25 2022-09-17
Fire an event when the user closes the popover by clicking outside of the popover region 1 2022-09-08 2022-09-23
The Object API should propagate out fresh model to any observers when .get() is called 1 2021-10-11 2022-08-22
新版本训练出现shape不匹配情况 2 2021-09-17 2022-01-19
404 when opening https://rustbyexample.com 3 2021-08-06 2022-09-27
Could not execute process `rustc -vV` (never executed) Caused by: Access is denied. (os error 5) 1 2022-05-16 2022-09-11
Have a `dart-runtime`-like option without Observatory 4 2021-04-13 2022-09-28
Dynamic data sampling scheduler implementation 1 2022-06-30 2022-09-09
Client Allocation Request for: PL - Bedrock 2 2022-03-16 2022-09-16
mmkv::MMKV::oldStyleWriteActualSize(unsigned long) crash on iOS 6 2021-08-31 2022-09-29
Continuous nonsense voice instructions 28 2022-05-20 2022-09-04
Updated user guide 0 2013-03-08 2021-12-28
Improved the ParameterBagInterface. 1 2015-06-11 2022-09-17