Skip to content

Instantly share code, notes, and snippets.

@MohamedElashri
Last active March 19, 2026 14:37
Show Gist options
  • Select an option

  • Save MohamedElashri/c97806f6e474045ccae38e7f1ef9f3f1 to your computer and use it in GitHub Desktop.

Select an option

Save MohamedElashri/c97806f6e474045ccae38e7f1ef9f3f1 to your computer and use it in GitHub Desktop.

Revisions

  1. MohamedElashri revised this gist Mar 19, 2026. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions install_qwen.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Follow the steps to install Qwen Code without root, and incorporating the nvm-ba

    ## Install Qwen Code Without Root

    ### Step 1 Install nvm
    ### Step 1: Install nvm

    ```bash
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    @@ -16,13 +16,13 @@ If `curl` is unavailable, use `wget`:
    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    ```

    ### Step 2 Reload your shell
    ### Step 2: Reload your shell

    ```bash
    source ~/.bashrc # or ~/.zshrc
    ```

    ### Step 3 Install Node.js 20 (LTS)
    ### Step 3: Install Node.js 20 (LTS)

    Qwen Code requires Node.js ≥ 20. Install and set it as default:

    @@ -32,14 +32,14 @@ nvm use 20
    nvm alias default 20
    ```

    ### Step 4 Create a user-local npm global directory
    ### Step 4: Create a user-local npm global directory

    ```bash
    mkdir -p ~/.npm-global
    npm config set prefix ~/.npm-global
    ```

    ### Step 5 Add it to your PATH
    ### Step 5: Add it to your PATH

    Add this line to your `~/.bashrc` or `~/.zshrc`:

    @@ -53,13 +53,13 @@ Then reload:
    source ~/.bashrc # or ~/.zshrc
    ```

    ### Step 6 Install Qwen Code
    ### Step 6: Install Qwen Code

    ```bash
    npm install -g @qwen-code/qwen-code@latest
    ```

    ### Step 7 Verify
    ### Step 7: Verify

    ```bash
    node --version # should be v20.x.x or higher
  2. MohamedElashri revised this gist Mar 19, 2026. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_qwen.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    The official script to install qwen code require root, but we can use this workaround to install qwen code without root.

    Here is the updated, complete guide to install Qwen Code without root, incorporating the nvm-based Node.js upgrade (because we have very old node version)
    Follow the steps to install Qwen Code without root, and incorporating the nvm-based Node.js upgrade (because we have very old node version)

    ## Install Qwen Code Without Root

  3. MohamedElashri revised this gist Mar 19, 2026. 1 changed file with 51 additions and 12 deletions.
    63 changes: 51 additions & 12 deletions install_qwen.md
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,68 @@
    The official script to install qwen code require root, but we can use this workaround to install qwen code without root.

    1. Create a user-local npm global directory
    Here is the updated, complete guide to install Qwen Code without root, incorporating the nvm-based Node.js upgrade (because we have very old node version)

    ## Install Qwen Code Without Root

    ### Step 1 — Install nvm

    ```bash
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    ```
    mkdir -p ~/.npm-global

    If `curl` is unavailable, use `wget`:

    ```bash
    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    ```

    2. Tell npm to use it
    ### Step 2 — Reload your shell

    ```bash
    source ~/.bashrc # or ~/.zshrc
    ```
    npm config set prefix ~/.npm-global

    ### Step 3 — Install Node.js 20 (LTS)

    Qwen Code requires Node.js ≥ 20. Install and set it as default:

    ```bash
    nvm install 20
    nvm use 20
    nvm alias default 20
    ```
    3. Add it to our PATH, add this line to our `~/.bashrc` or `~/.zshrc`

    ### Step 4 — Create a user-local npm global directory

    ```bash
    mkdir -p ~/.npm-global
    npm config set prefix ~/.npm-global
    ```

    ### Step 5 — Add it to your PATH

    Add this line to your `~/.bashrc` or `~/.zshrc`:

    ```bash
    export PATH="$HOME/.npm-global/bin:$PATH"
    ```

    4. Reload our shell
    ```
    Then reload:

    ```bash
    source ~/.bashrc # or ~/.zshrc
    ```

    5. Now install Qwen Code without `sudo`
    ```
    ### Step 6 — Install Qwen Code

    ```bash
    npm install -g @qwen-code/qwen-code@latest
    ```
    6. Verify
    ```

    ### Step 7 — Verify

    ```bash
    node --version # should be v20.x.x or higher
    qwen --version
    ```
    ```

  4. MohamedElashri revised this gist Mar 19, 2026. 1 changed file with 18 additions and 8 deletions.
    26 changes: 18 additions & 8 deletions install_qwen.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,29 @@
    The official script to install qwen code require root, but we can use this workaround to install qwen code without root.

    # 1. Create a user-local npm global directory
    1. Create a user-local npm global directory
    ```
    mkdir -p ~/.npm-global
    ```

    # 2. Tell npm to use it
    2. Tell npm to use it
    ```
    npm config set prefix ~/.npm-global

    # 3. Add it to our PATH, add this line to your ~/.bashrc or ~/.zshrc
    ```
    3. Add it to our PATH, add this line to our `~/.bashrc` or `~/.zshrc`
    ```
    export PATH="$HOME/.npm-global/bin:$PATH"
    ```

    # 4. Reload our shell
    4. Reload our shell
    ```
    source ~/.bashrc # or ~/.zshrc
    ```

    # 5. Now install Qwen Code without sudo
    5. Now install Qwen Code without `sudo`
    ```
    npm install -g @qwen-code/qwen-code@latest

    # 6. Verify
    ```
    6. Verify
    ```
    qwen --version
    ```
  5. MohamedElashri revised this gist Mar 19, 2026. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions install_qwen.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    The official script to install qwen code require root, but we can use this workaround to install qwen code without root.

    # 1. Create a user-local npm global directory
    mkdir -p ~/.npm-global

    # 2. Tell npm to use it
    npm config set prefix ~/.npm-global

    # 3. Add it to our PATH, add this line to your ~/.bashrc or ~/.zshrc
    export PATH="$HOME/.npm-global/bin:$PATH"

    # 4. Reload our shell
    source ~/.bashrc # or ~/.zshrc

    # 5. Now install Qwen Code without sudo
    npm install -g @qwen-code/qwen-code@latest

    # 6. Verify
    qwen --version
  6. MohamedElashri created this gist Mar 19, 2026.
    86 changes: 86 additions & 0 deletions qwen_mcp.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@

    ## Prerequisites

    First, create the virtual environment using `uv` and install both MCP servers into it. The default path used here is `~/.local/envs/.venv_mcp`**adjust this path if you want your env somewhere else**.

    ```bash
    # Create the virtual environment
    uv venv ~/.local/envs/.venv_mcp

    # Install both MCP servers into it
    uv pip install --python ~/.local/envs/.venv_mcp root-mcp cerngitlab-mcp
    ```

    After this, both servers are available as executables inside `~/.local/envs/.venv_mcp/bin/`.



    ## Qwen Code Configuration

    Qwen Code reads MCP servers from `mcpServers` in `settings.json`. You have two scopes: [qwenlm.github](https://qwenlm.github.io/qwen-code-docs/en/users/features/mcp/)
    - **Project scope** (only current project): `.qwen/settings.json` in your project root
    - **User scope** (all projects): `~/.qwen/settings.json`

    Create or edit your chosen `settings.json` and add the following:

    ```json
    {
    "mcpServers": {
    "root-mcp": {
    "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/root-mcp",
    "args": ["--data-path", "/path/to/your/root/files"],
    "timeout": 30000
    },
    "cerngitlab": {
    "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/cerngitlab-mcp",
    "args": []
    }
    }
    }
    ```

    > **Adjustments to make:**
    > - Replace `/home/YOUR_USERNAME/` with your actual home directory (run `echo $HOME` to find it). On Linux this is typically `/home/yourname`, on macOS `/Users/yourname`.
    > - Replace `/path/to/your/root/files` with the directory containing your `.root` files.
    > - If you placed the env in a different location than `~/.local/envs/.venv_mcp`, update the paths accordingly.
    > - If you want the servers available globally across all projects, write to `~/.qwen/settings.json` instead.

    ***

    ## Optional: CERN GitLab Token

    By default `cerngitlab-mcp` only accesses public repositories. To unlock private repos and additional tools like `search_code` and `search_issues`, add your CERN GitLab token:

    ```json
    "cerngitlab": {
    "command": "/home/YOUR_USERNAME/.local/envs/.venv_mcp/bin/cerngitlab-mcp",
    "args": [],
    "env": {
    "CERNGITLAB_TOKEN": "glpat-xxxxxxxxxxxx"
    }
    }
    ```

    Generate a token at `https://gitlab.cern.ch/-/user_settings/personal_access_tokens` with the `read_api` scope. You can also reference an existing shell variable instead of hardcoding: `"CERNGITLAB_TOKEN": "$CERNGITLAB_TOKEN"`.

    ***

    ## Verify

    Restart Qwen Code in your project directory, then run:

    ```bash
    qwen mcp list
    ```

    Both `root-mcp` and `cerngitlab` should appear as connected. If a server shows "Disconnected", double-check that the `command` path is the exact absolute path to the binary inside your venv, you can verify with:

    ```bash
    ls ~/.local/envs/.venv_mcp/bin/
    ```