DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Mark Witt
Mark Witt

Posted on

Creating a custom VSCode Terminal Profile for using Rosetta on an M1 Mac (Apple Silicon)

Why do this?

Many programs and packages still do not support the ARM architecture used on the new Apple M1 chip.
If you are a developer dealing with older codebases, you may have already had issues installing npm dependencies or running specific tools.

Luckily, Apple provides us with the Rosetta emulation layer.
It enables us to emulate the x86 architecture to run all the programs made for older Macs, with a little performance decrease when compared to apps optimized for M1.

Rosetta Terminal

When installing build tools like CocoaPods, you have to run your whole terminal session with Rosetta enabled.

A prevalent practice to achieve this is to create a copy of the Terminal.app, click "Get Info" and enable the flag "Open using Rosetta". Now you have a second terminal that is always running as Rosetta.
RosyTerm copy of Terminal app using Rosetta

How to do this in VSCode

I very much enjoy using the integrated Terminal in VSCode because I don't have to switch windows so often and can continue coding while running processes like building my app or installing dependencies.

How to create a custom terminal profile:

  • Open Visual Studio Code
  • Use cmd+shift+p to open the Command Palette.
  • Type "Open Settings (JSON)" and press enter
  • In the settings.json file, search for the property terminal.integrated.profiles.osx, it should look similar to this:

    "terminal.integrated.profiles.osx": {
        "bash": {
        "path": "bash",
        "args": ["-l"],
        "icon": "terminal-bash"
        },
        "zsh": {
        "path": "zsh",
        "args": ["-l"]
        },
        "fish": {
        "path": "fish",
        "args": ["-l"]
        },
        "tmux": {
        "path": "tmux",
        "icon": "terminal-tmux"
        },
        "pwsh": {
        "path": "pwsh",
        "icon": "terminal-powershell"
        }
    }
    
  • Add this property:

    "terminal.integrated.profiles.osx": {
     ....,
      "rosetta": {
        "path": "arch",
        "args": ["-x86_64", "zsh", "-l"],
        "overrideName": true
      }
    }
    
  • Save the file

Tada! You now have a dedicated rosetta Terminal profile in VSCode

Click the dropdown arrow at the right side of your VSCode terminal. You should see the option "rosetta".

Rosetta profile in terminal dropdown

If it doesn't work or you have anything else you want to tell me, feel free to hit me up anytime on Twitter.

Top comments (7)

Collapse
 
jimteva profile image
JimTeva

Great post, thank you!

For Visual Studio Code on mac OS, I would update to this:

  • Open Visual Studio Code
  • Use cmd+shift+p to open the Command Palette.
  • Search for "Open Settings", you will find two options "Open Default Settings (JSON)" and "Open Settings (JSON)". The first is a read-only file. You can only edit the second.
  • Select "Open Settings (JSON)" and add this:
"terminal.integrated.profiles.osx": {
  "rosetta": {
    "path": "arch",
    "args": ["-x86_64", "zsh", "-l"],
    "overrideName": true
  }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
markwitt_me profile image
Mark Witt

Thanks a lot for your feedback, it is greatly appreciatedπŸ™

Collapse
 
devalibaba profile image
DevAlibaba

Damn good post! Wonderful!!!

Collapse
 
markwitt_me profile image
Mark Witt

Thanks a lot for the positive feedbackπŸ™

Collapse
 
yulin profile image
Yulin Chen

Exactly what I needed, thanks!

Collapse
 
markwitt_me profile image
Mark Witt

Iβ€˜m happy if I could help :)

Collapse
 
pablorr100 profile image
Pablo Ruiz • Edited on

Great post !

One question, how do I configure to use that terminal for Running or Debugging files ?
Do you need to add something in the launch.json file ?

I am trying to run a FastAPI in a Python virtual environment I created under Rosetta to point to x86 wheels, and if not running under Rosetta I get:

  File "/Users/pabloruiz/.pyenv/versions/3.9.13_x86/lib/python3.9/pathlib.py", line 558, in _select_from
    with scandir(parent_path) as scandir_it:
FileNotFoundError: [Errno 2] No such file or directory: '/System/Volumes/Data/Network/Servers/dubious/Binaries1'
Enter fullscreen mode Exit fullscreen mode

Hope I can fix this if running under Rosetta

Collapse
 
jungil_kim_0602abfd87d102 profile image
Jungil Kim • Edited on

Working react native in xcode swift, I need to add cocoapods for adding react native to xcode where some part of binaries are in x86. After setting and selecting Resetta, typing arch shows "i386" response. This reall helps, thanks Mark Witt and JimTeva.

Build Anything...


Use any Linode offering to create something for the DEV x Linode Hackathon 2022. A variety of prizes are up for grabs, inculding $1,000 USD. πŸ‘€

β†’ Join the Hackathon <-