How to Set Up VS Code for Local Development on a Free Dev Tier Account

I struggled quite a bit to set up my vs code local environment, so hopefully this short guide helps anyone in a similar situation.

  1. If using windows read this :
    At the time of this writing, I believe there’s a bug in the vscode Palantir extension when running on Windows. The Gradle plugin com.palantir.gradle.functions.python seems to attempt to apply POSIX file permissions even though the os doesn’t support them, which causes the build to fail.

    Here’s a part of the stacktrace I was getting:

    UnsupportedOperationException

    Stacktrace: java.lang.UnsupportedOperationException
    at java.base/java.nio.file.Files.setPosixFilePermissions(Files.java:2166)
    at com.palantir.gradle.functions.python.tasks.server.InstallFunctionsPythonRuntimeTask.applyPermissions(InstallFunctionsPythonRuntimeTask.java:149)
    at com.palantir.gradle.functions.python.tasks.server.InstallFunctionsPythonRuntimeTask.processEntry(InstallFunctionsPythonRuntimeTask.java:143)
    at com.palantir.gradle.functions.python.tasks.server.InstallFunctionsPythonRuntimeTask.extract(InstallFunctionsPythonRuntimeTask.java:115)
    at com.palantir.gradle.functions.python.tasks.server.InstallFunctionsPythonRuntimeTask.installFunctionsPythonRuntimeBinary(InstallFunctionsPythonRuntimeTask.java:89)

  2. Due to this bug, I’d recommend just using WSL in the meantime. So install it with Ubuntu or your prefered distro. You will find the instructions on how to install and set up WSL here.
    Note : If even after using the command wsl –install ubuntu and rebooting WSL seems to not find the installation. Just install ubuntu from microsoft store. I personnaly chose 20.04.6 LTS for no particular reason.

  3. Open vs code on windows and install the WSL extension from Microsoft.

  4. Boot up your Ubuntu WSL installation and type in the CLI code . to lauch vs code in Ubuntu.

  5. Once inside vs code, open up a terminal and create a directory where you will store your projects using this command : mdkir projects.
    (do not try to mnt your project or else you will just end up using the same filesystem as windows)

  6. On your WSL instance, open up the extensions window in vscode and drog and drop the Palantir vs code extension from your Windows machine and install it.

  7. Now in vs code make sure you are in the projects folder we created. Once you are clone your repo using your repo link.
    You can get it by heading over to your repo in Foundry, hitting the button “Work Locally” and choosing clone repository at the bottom.
    Once this is done, open your project if not done already.

IMPORTANT: DO NOT INSTALL ANY OF VS CODE JAVA OR GRADLE EXTENSIONS.
This will completely mess up your environment. Here’s why :
Local environnement only works with Java versions up to Java 17 (Palantir docs).
Also since we’re using a free dev tier account, I believe we only have access to specific version of ressources.

  • We can only use Gradle 7.6.4. Trying to download any other version by modifying the gradlew file will cause a network error because the file doesn’t exist in our available assets. (You can try it for yourself by finding the link in your gradlew file, paste the unmodified link in your browser and it should download gradle-7.6.4-bin.zip. Now try changing it to any other version. You will get a network error)
  • By installing the recommend java extensions, in particular Language Support for Java™ by Red Hat. It will force Java version to 21 which will cause the error Unsupported class file major version 65
  • The gradle extension kept installing different versions of gradle for whatever reason which would cause errors of mismatched versions.
  1. Install relevant python extensions (Pylance, debugger, etc)

  2. Download Java 17 with these commands : sudo apt update , then sudo apt install openjdk-17-jdk.

  3. Type the command update-alternatives --list javaand take note of the Java 17 path.

  4. Type nano ~/.bashrc and add this at the bottom (change the path if you don’t have the same one)
    export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
    export PATH=$PATH:$JAVA_HOME/bin

    Also add this at the same time (optional I think) :
    export FOUNDRY_HOSTNAME=<your-foundry-domain> (without https://www)
    export FOUNDRY_USERNAME=<your-username>

  5. save, exit and type source ~/.bash for the changes to take effect.

  6. Now run ./gradlew build

  7. If nothing fails, great skip to 14. Else

    1. If you get an error about bearerToken:
      I’m not sure this is what fixed it but try that

      1. Set your FOUNDRY_HOSTNAME and FOUNDRY_USERNAME in bashrc or just type it in the current shell to temporarily store them.
      2. Open the Palantir extension on the left, refresh your token, add Palantir to your trusted sources when prompted and copy your refreshed token.
      3. Paste it inside the CLI, press enter and try ./gradlew build again.
    2. If you get the error ./gradlew: line 145: ORG_GRADLE_PROJECT_trustStore: unbound variable. You need to create and install your Foundry cert into your Ubuntu system trust.

    3. Use this command to create the certificate:
      HOST=<your foundry domain> (without https://www)
      echo | openssl s_client -showcerts -servername “$HOST” -connect “$HOST:443” 2>/dev/null | openssl x509 -outform PEM > palantir_foundry_ca.crt

    4. Copy it to Ubuntu system trust
      sudo cp palantir_foundry_ca.crt /usr/local/share/ca-certificates/palantir_foundry_ca.crt
      update your certificates

      sudo update-ca-certificates
      Now try to build again.

  8. Almost done! Now that everything is built, let’s verify that your python environnement fully works.
    Open your function file and try to run it, if you get the error <so_much_text> maestro permission denied. This is because maestro doesn’t have execute permission, we’ll add them.

    1. First, confirm it exists in this path (normally the path should be the same as me if you left everything to default and used the same paths as me to create your project).

      Replace with the appropriate values and paste the command into your terminal :
      ls -l /home/<YOUR-LINUX-USER>/.vscode-server/extensions/palantir.authoring-vscode-extension-<YOUR-EXTENSION-VERSION>/build/authoring-vs-code-extension-executables/maestro/linux/amd64/maestro
      Note: You can find the version of Palantir extension on it’s vsix file you downloaded previously.

    2. Once you’ve confirmed the location, copy the path, you’ll need it.
      Now type `chmod +x /path/to/.maestro to give it execute permission.
      Note: you will probably have to reapply this permission each time the Palantir extension gets updated.

Et voilà! Everything should work at this point, even live preview!

3 Likes