Skip to content
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

Automatically run other cells if it's needed #1585

Open
gojanpaolo opened this issue Aug 26, 2024 · 10 comments
Open

Automatically run other cells if it's needed #1585

gojanpaolo opened this issue Aug 26, 2024 · 10 comments

Comments

@gojanpaolo
Copy link

gojanpaolo commented Aug 26, 2024

Is there a way to automatically run other cells if it's needed?
For example, if I have the following

```
export url="https://example.com"
```

```
curl "${url}/v1"
```

```
curl "${url}/v2"
```

Let's say I have a new session, if I run curl "${url}/v1", it should automatically run the first block because it needs the url variable. But it should not automatically run curl "${url}/v2.

Same goes if I run curl "${url}/v2, it should also automatically run the first block. But it should not automatically run curl "${url}/v1"

VS Code's REST Client extension has this kind of feature: https://github.com/Huachao/vscode-restclient?tab=readme-ov-file#variables

Thanks!

@sourishkrout
Copy link
Member

sourishkrout commented Aug 26, 2024

Hi @gojanpaolo! Thanks for filing this issue. We are considering adding direnv support which, when allowed/authorized, will execute .envrc (an arbitrary shell/bash script file that can be used for initialization).

If the URL is static, you can drop it into a .env or .env.local at the base of your project, and Runme will load it when you start up.

e.g. ~/project/myrepo/.env.local:

url="https://example.com"

If you change values, please click the Reset Session button in the notebook toolbar (screenshot below).

Screenshot 2024-08-26 at 10 23 45 AM

@gojanpaolo
Copy link
Author

gojanpaolo commented Aug 26, 2024

@sourishkrout Thanks for the response! I think .env would solve a few of our use cases.

But what if the value is dynamic? e.g.

```
latest_version=$(curl ... | jq | .latest_version)
```

```
install $latest_version
```

```
uninstall $latest_version
```

@gojanpaolo
Copy link
Author

gojanpaolo commented Aug 27, 2024

I saw this: #519
But it looks like it doesn't work
image

I was expecting echo "$__" to also print foo

@gojanpaolo
Copy link
Author

Looks like .env also doesn't seem to work
image

@sourishkrout
Copy link
Member

@gojanpaolo did you hit the "Reset Session" button as shown above? The .env will be populated at session creation by either restarting VS Code or "Reset Session", @gojanpaolo.

@gojanpaolo
Copy link
Author

@sourishkrout Yes I did. And I also restarted VS Code

@sourishkrout
Copy link
Member

sourishkrout commented Aug 28, 2024

Are you on Windows using PowerShell by chance @gojanpaolo?

We currently only support WSL2 on Windows: https://docs.runme.dev/why#known-limitations

@gojanpaolo
Copy link
Author

I'm on Windows and use git bash

@sourishkrout
Copy link
Member

Unfortunately, git bash is not Unix/POSIX and thus not supported.

However, here's how you can get Windows Subsystem for Linux working: https://docs.runme.dev/how-runme-works/windows

@gojanpaolo
Copy link
Author

gojanpaolo commented Aug 28, 2024

Ah, I just now tried in WSL and it's working as expected!
I think this is the 2nd or 3rd tool that I want to use but only works on WSL. Maybe I need to switch to WSL as my main.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@sourishkrout @gojanpaolo and others