Fork me on GitHub
#off-topic
<
2022-08-25
>
Martynas Maciulevičius17:08:36

Javascript doesn't have classpaths. And currently I ran into an issue where I want to have two different execution modes of my app and if I merely install/uninstall one dependency I can run either the first, or the second part of the app (one or the other doesn't work) 😄 (this is enabled by autolinking in react native. When I install a specific package then the native app starts to expect things that I don't want it to expect.)

😰 1
quoll20:08:48

I’m trying to remember a command, but I’ve gone blank. Traditionally, when starting a script I would use #!/bin/sh or maybe #!/bin/bash. If I’m using another language, then it might be #!/bin/python. But I know there is a command that will find the correct interpreter to run instead of using a hard coded path like this (at least, I believe I’ve seen it on macos). Can anyone recall the name of it for me, please?

hiredman20:08:47

You may be thinking of using env

quoll21:08:02

thank you!

hiredman21:08:28

I think env just looks for the program in your path, but at least on linux, you don't need to specify the full path in the shebang, and it will use the your path to find the interpreter anyway

quoll21:08:05

This was exactly the program I was looking for, thank you

quoll21:08:41

I wrote a python script, and in trying to add the #! at the top, I realized that my MacOS has it at: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 Well, that isn’t portable. I figured that using env to find it would be much better. I just couldn’t recall the name

quoll21:08:01

and of all the places I could ask, this was the first to come to mind 🙂

dpsutton21:08:41

is there no softlink in /bin/ or equivalent that points to that python3? I thought that’s usually how it worked

quoll22:08:07

not on my system, no

👍 1
rolt21:08:50

it's quite common to have multiple python versions installed and activate one by prepending the PATH

rolt21:08:56

(well, at least 10 years ago, i don't know about now)

p-himik21:08:43

Nowadays pyenv is much easier to use.

sventechie21:08:27

or pipenv generally causes less headache these days

quoll22:08:08

my system has neither of these. I know that package managers makes these things easy to install, but I’m presuming that the people I’m giving the file to won’t have them, and I’d rather not ask that they install something extra if it can be avoided

Martynas Maciulevičius04:08:57

I use virtualenv for my python things. But it's possible that you want to run your script without additional wrappers :thinking_face:

p-himik05:08:26

Oh yeah, even with all of those things you still should run your scripts with env.

Martynas Maciulevičius05:08:32

If you use virtualenv then env would give you the python that you want because you hardcode it via virtualenv :thinking_face: But that's an additional step though