# Vscode and wp-cli

**URL:** <https://community.localwp.com/t/vscode-and-wp-cli/43924>\
**Category:** WordPress Questions\
**Tags:** windows\
**Created:** [July 28, 2024, 9:36pm UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924 "2024-07-28T21:36:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Musaad](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@Musaad](https://community.localwp.com/u/Musaad)\
**Post date:** [July 28, 2024, 9:36pm UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/1 "2024-07-28T21:36:31Z")

</div>

Please help! I have been trying to use **WP-CLI** in my **Visual Studio Code**  **while Local by Flywheel** is open with the bash terminal, but it seems that I can only work from the local terminal. I want to use **Visual Studio Code** instead.

---

<div class="post-metadata">

**Author:** ![emmtre](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/emmtre/32/15116_2.png) [@emmtre](https://community.localwp.com/u/emmtre)\
**Post date:** [July 29, 2024, 7:51am UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/2 "2024-07-29T07:51:40Z")

</div>

I use macOS but the principle should be the same. You have to find the shell script that sets the environment variables and starts the shell for the website in question. In macOS you will find the shell scripts for the Local websites in the users `Application Support` folder. You can start the shell by enter the path to the shell script but I have created an alias in the bash profile for each website to quickly start a terminal session in VS Code.

```auto
/Users/USERNAME/Library/Application\ Support/Local/ssh-entry/QtMpqLkVF.sh

```

```auto
alias website.sh="/Users/USERNAME/Library/Application\ Support/Local/ssh-entry/QtMpqLkVF.sh"

```

 ![vs_code](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/3X/5/8/58c22e03cc1b66198c98945e329c2a7f4730a3e9.jpeg)

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [July 29, 2024, 4:27pm UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/3 "2024-07-29T16:27:10Z")

</div>

@emmtre 's solution is cool! Another option that we’ve thought about implementing in Local core is to use [direnv](https://direnv.net/).

You can still use direnv with Local (and any terminal, including VS Code) today with an addon!

Clay, the original author of Local (Pressmatic) created this addon which adds the `.envrc` needed for direnv to the `<site>/app/` folder.

- [GitHub - gravitywiz/local-addon-direnv: Local Add-on that automatically generates .envrc files for direnv to configure CLI variables.](https://github.com/gravitywiz/local-addon-direnv)

You can download that addon and install it from “Addons \> Installed \> Install from disk” in Local:

- [Releases · gravitywiz/local-addon-direnv · GitHub](https://github.com/gravitywiz/local-addon-direnv/releases)

 ![Zight 2024-07-29 at 9.22.58 AM.jpg](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/3X/9/f/9f7141c42712668d2c5757c0df34fdb223075bc2.jpeg)

---

<div class="post-metadata">

**Author:** ![Musaad](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@Musaad](https://community.localwp.com/u/Musaad)\
**Post date:** [July 30, 2024, 1:06am UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/4 "2024-07-30T01:06:17Z")

</div>

This is absolutely awesome! It worked perfectly. Thank you so much!

---

<div class="post-metadata">

**Author:** ![emmtre](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/emmtre/32/15116_2.png) [@emmtre](https://community.localwp.com/u/emmtre)\
**Post date:** [July 31, 2024, 4:28am UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/6 "2024-07-31T04:28:10Z")

</div>

> [@ben.turner](#):
>
> Another option that we’ve thought about implementing in Local core is to use [direnv](https://direnv.net/).
> 
> You can still use direnv with Local (and any terminal, including VS Code) today with an addon!

Many thanks for the info. Sounds like a good idea I think. I had no idea this plugin even existed. I’ll have to test when I have the chance.

---

<div class="post-metadata">

**Author:** ![Musaad](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@Musaad](https://community.localwp.com/u/Musaad)\
**Post date:** [August 10, 2024, 12:56am UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/7 "2024-08-10T00:56:17Z")

</div>

“This is also great. Thank you so much.”

---

<div class="post-metadata">

**Author:** ![Gray](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/gray/32/15122_2.png) [@Gray](https://community.localwp.com/u/Gray)\
**Post date:** [April 9, 2025, 9:49pm UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/8 "2025-04-09T21:49:01Z")

</div>

It should be mentioned that Local requires the file format to be in a .tar.gz format, so make sure to download [https://github.com/gravitywiz/local-addon-direnv/archive/refs/tags/1.0.0.tar.gz](https://github.com/gravitywiz/local-addon-direnv/archive/refs/tags/1.0.0.tar.gz) and import that one.

Unfortunately for me, installing this in the latest Local (Version 9.2.3+6776) doesn’t work since I pretty soon get the message:

```auto
**Uh-oh! Local ran into an error.**
TypeError: Cannot read properties of undefined (reading 'toString')

Stack Trace:
in Unknown
in o
in div
[etc]

```

and then if I restart local, this add-on is no longer listed in my “installed” list of applications.

Is it possible that this add-on was only made for Local Classic (used docker) since it was last update in 2021?

Per Ben’s comment, I’d love to see this just integrated directly, since I imagine many of us are using terminals integrated into our preferred IDEs.

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [April 10, 2025, 2:26pm UTC](https://community.localwp.com/t/vscode-and-wp-cli/43924/10 "2025-04-10T14:26:48Z")

</div>

I experienced that same issue with the archive you linked to.

I think the issue is that the `tar.gz` file is just the source code. For an actual compiled build, you’ll want to install the `tgz` archive:

- [https://github.com/gravitywiz/local-addon-direnv/releases/download/1.0.0/direnv-1.0.0.tgz](https://github.com/gravitywiz/local-addon-direnv/releases/download/1.0.0/direnv-1.0.0.tgz)

 ![Zight 2025-04-10 at 7.25.57 AM](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/3X/d/e/de806f19d40c7b0a9ea40917f9b4cfb301005da5.jpeg)
