withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.06k stars 63 forks source link

create devcontainer feature for fig #2313

Open nick-youngblut opened 1 year ago

nick-youngblut commented 1 year ago

Sanity checks

Feature Details

Description:

VS Code devcontainers can container features, such as:

    "features": {
             "ghcr.io/devcontainers/features/docker-in-docker:2": {
             "version": "latest"
        },
           "ghcr.io/devcontainers/features/aws-cli:1": {
            "version": "latest"
        }
}

It would be great to have a fig feature for devcontainers, especially given the current issues in regards to headless installs of fig on linux machines (e.g., https://github.com/withfig/fig/issues/2219 and https://github.com/withfig/fig/issues/2095).

grant0417 commented 1 year ago

Hey @nick-youngblut, we actually do have a devcontainer feature, https://github.com/withfig/features

It currently only supports our CLI tools and we don't have good docs on how to best use it currently. Hopefully I can get around to improving that soon!

nick-youngblut commented 1 year ago

Thanks @grant0417 for letting me know! Where is that documented in the Fig manual? I must have missed it.

nick-youngblut commented 1 year ago

It appears that the feature doesn't always work out-of-the-box:

✘ bash ~/.bashrc integration check: /home/gitpod/.bashrc does not source pre integration

  Run fig integrations install dotfiles to reinstall shell integrations for bash
Attempting to fix automatically...
Re-running check...

✔ bash ~/.bashrc integration check
✘ bash ~/.profile integration check: /home/gitpod/.profile does not source pre integration

  Run fig integrations install dotfiles to reinstall shell integrations for bash
Attempting to fix automatically...
Re-running check...

✔ bash ~/.profile integration check
● File does not exist: /home/gitpod/.zshrc
● File does not exist: /home/gitpod/.zprofile
● /home/gitpod/.config/fish/conf.d/00_fig_pre.fish does not exist.
● /home/gitpod/.config/fish/conf.d/99_fig_post.fish does not exist.
✘ Fig Integration: Figterm is not running in this terminal, please try restarting your terminal

  FIG_TERM=

✘ Doctor found errors. Please fix them and try again.

If you are not sure how to fix it, please open an issue with fig issue to let us know!
Or, email us at hello@fig.io!

I'm using VS Code with a remote ssh connection to a remote Ubuntu machine. My feature setup in my devcontainer.json:

        "ghcr.io/withfig/features/fig:1": {
            "version": "latest"
        }

After rebuilding the devcontainer, I ran fig login, and logged in via github (I had to manually open my browser and go to the website). After logging in, I ran fig source, but nothing was actually sourced. I then ran fig doctor, and I got the output shown above.

Killing the terminal and starting a new one did enable fig source, but I still get the following from fig doctor:

● File does not exist: /home/gitpod/.zshrc
● File does not exist: /home/gitpod/.zprofile
● /home/gitpod/.config/fish/conf.d/00_fig_pre.fish does not exist.
● /home/gitpod/.config/fish/conf.d/99_fig_post.fish does not exist.
✘ Fig Integration: Figterm is not running in this terminal, please try restarting your terminal

  FIG_TERM=

✘ Doctor found errors. Please fix them and try again.
grant0417 commented 1 year ago

Could you try running fig integrations install dotfiles

nick-youngblut commented 1 year ago

Could you try running fig integrations install dotfiles

Thanks for the suggestion! I ran fig integrations install dotfiles, which completed successfully (output message: Installed!). However, that didn't help. I still had to kill my terminal and start another in order for fig source to take effect.

grant0417 commented 1 year ago

I added docs for installing the feature and getting authed: https://fig.io/user-manual/install/devcontainer-codespaces

Still need to figure out what is going on with the dotfiles not being installed like you would expect as you mentioned.

nick-youngblut commented 1 year ago

Thanks for adding the docs!

I can confirm that I'm still getting the error:


✘ Fig Integration: Figterm is not running in this terminal, please try restarting your terminal

  FIG_TERM=

...when I run fig doctor. Restarting my terminal, as suggested, does not help.

My fig diagnostic output:

fig-details:
  - 2.14.2
hardware-info:
  - model: 
  - model-id: 
  - chip-id: Intel(R) Xeon(R) Gold 6258R CPU @ 2.70GHz
  - cores: 18
  - mem: 188.71 GB
os-info:
  - kernel: 5.15.0-58-generic
  - distro: "Ubuntu 20.04.5 LTS"
  - distro-version: "20.04.5 LTS (Focal Fossa)"
environment:
  - shell: /usr/bin/bash
  - terminal: vscode
  - cwd: /workspaces/genome_assembly
  - exe-path: /usr/bin/fig
  - install-method: unknown
  - env-vars:
    - SHELL: /bin/bash
    - FIG_SET_PARENT_CHECK: 1
    - TERM: xterm-256color
    - FIG_PID: 6402
    - PATH: /opt/conda/bin:/opt/conda/condabin:/vscode/vscode-server/bin/linux-x64/441438abd1ac652551dbe4d408dfcec8a499b8bf/bin/remote-cli:/home/gitpod/.local/bin:/opt/conda/bin:/home/gitpod/.local/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/gitpod/.fig/bin:/opt/homebrew/sbin:/home/gitpod/.cargo/bin:/home/gitpod/bin/
nick-youngblut commented 1 year ago

I should note that since there is no devcontainer feature for mamba (AFAIK), I am installing mamba via the devcontainer postCreateCommand. So, the conda/mamba initialization blocks are appended to my ~/.bashrc after the Fig post block.

Still, even when I skip the conda/mamba installation in my postCreateCommand, I still get the fig doctor error:

✘ Fig Integration: Figterm is not running in this terminal, please try restarting your terminal

  FIG_TERM=
nick-youngblut commented 1 year ago

I should also note that there is nothing in my _FIG_LOCAL_BIN (set to ~/.local/bin). That directory is empty in my devcontainer environment, while on my mac, ~/.local/bin contains a symlink to the fig executable. However, creating the symlink did not help with the FIG_TERM= issue.

There is also nothing in ~/.fig/bin/ for my devcontainer environment, while on my mac, ~/.fig/bin/ contains figterm.

grant0417 commented 1 year ago

You can manually fix the FIG_TERM= issue by running figterm directly, I will make sure the next version of the CLI.

Also are you using codespaces or local dev containers?

nick-youngblut commented 1 year ago

How do I use figterm directly? The figterm docs just state: Usage: figterm [-- <COMMAND>...], so there's not a lot of guidance on its direct usage.

Also are you using codespaces or local dev containers?

I'm using a dev container running on a remote machine (ssh connection via VS Code).

grant0417 commented 1 year ago

You can just directly run figterm it doesnt need any arguments, then run fig doctor and it should work.

nick-youngblut commented 1 year ago

Thanks @grant0417 ! I should have just tried figterm by itself; I just couldn't tell what figterm actually did based on the script help doc.