# Gcloud with start up script on jupyter

**URL:** <https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304>\
**Category:** Help\
**Tags:** terra\
**Created:** [May 10, 2025, 4:11am UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304 "2025-05-10T04:11:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![camancuso](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@camancuso](https://help.anvilproject.org/u/camancuso)\
**Post date:** [May 10, 2025, 4:11am UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/1 "2025-05-10T04:11:03Z")

</div>

I’m trying to copy some files from one terra gcp bucket to a computational environment that I spin up. I’m trying to use the command (made up bucket id)

`gcloud storage cp --recursive "gs://fc-1111-111-1111-111111/module_data/module_1/part2" /home/jupyter`

this ins’t the same bucket that the workspace is in, but a bucket I have access to. It works well with RStudio using something like

`gcloud storage cp --recursive "gs://fc-1111-111-1111-111111/module_data/module_1/part2" /home/rstudio`

I’ve noticed some differences in Rstudio and jupyter in permission access and I have tried stuff like

```auto
cd /home/jupyter
mkdir data
chmod -R ug+rw data
gcloud storage cp --recursive "gs://fc-1111-111-1111-111111/module_data/module_1/part2" /home/jupyter/data
chmod -R ug+rw data

```

Is there a difference using gcloud on Rstudio vs Jupyter? Is there an example of using a start up script using `gcloud storage cp` on jupyter?

Thanks!

---

<div class="post-metadata">

**Author:** ![Javier-CP](https://yyz1.discourse-cdn.com/flex027/user_avatar/help.anvilproject.org/javier-cp/32/168_2.png) [@Javier-CP](https://help.anvilproject.org/u/Javier-CP)\
**Post date:** [May 12, 2025, 6:39pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/2 "2025-05-12T18:39:29Z")

</div>

Hi @camancuso

> I’ve noticed some differences in Rstudio and jupyter in permission access

Could you elaborate on this? Is this affecting you in a specific way?

You should not expect any differences as long as gcloud version is the same for both images. The only case for a potential difference could come in regards to different base images, i.e. Ubuntu 20 vs Ubuntu 22.

Javier

---

<div class="post-metadata">

**Author:** ![camancuso](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@camancuso](https://help.anvilproject.org/u/camancuso)\
**Post date:** [May 13, 2025, 11:52am UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/3 "2025-05-13T11:52:45Z")

</div>

Not sure how to elaborate on this more. In Rstudio, I can use `gcloud storage cp` in a start up script and it copies data from a given GCP bucket to the computational environment that is built, where as this does not work for a start up script within a Jupyter environment for me (nothing gets copied over when the computational environment is built). I would imagine, like you said, that it is a difference between base image for RStudio and Jupyter. I can’t find logs generated during building the computational environments so I have no idea why it is not copying.

I have one Template workspace for a workshop I’ll be running. This workspace contains all the data needed for 8 different modules. For each module there is a start up script that lists the needed extra packages to be built and what data needs to be copied. So when a module starts the users can use the module specific start up script and then have everything they need for those few hours they are doing that module. Right now any module that needs Jupyter just can’t use a start up script and we need to manually go into the terminal (or call terminal commands for a notebook) to get the data from the template bucket. It isn’t a big problem, but I just can’t figure out why `gcloud storage cp` doesn’t work on the Jupyter image.

---

<div class="post-metadata">

**Author:** ![Javier-CP](https://yyz1.discourse-cdn.com/flex027/user_avatar/help.anvilproject.org/javier-cp/32/168_2.png) [@Javier-CP](https://help.anvilproject.org/u/Javier-CP)\
**Post date:** [May 22, 2025, 1:41pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/4 "2025-05-22T13:41:55Z")

</div>

@camancuso

Thanks for sharing this. Just wanted to let you know that the issue has been identified and a fix is in progress. Will post again when it’s been fixed.

Javier

---

<div class="post-metadata">

**Author:** ![Javier-CP](https://yyz1.discourse-cdn.com/flex027/user_avatar/help.anvilproject.org/javier-cp/32/168_2.png) [@Javier-CP](https://help.anvilproject.org/u/Javier-CP)\
**Post date:** [May 28, 2025, 4:53pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/5 "2025-05-28T16:53:54Z")

</div>

Hi @camancuso

UPDATE: The issue is now fixed. To successfully use `gcloud` commands in a Jupyter startup script and subsequently after startup, the `gcloud` commands in the Jupyter startup script must be in the following block:

```auto
sudo -u jupyter -g users bash -c "{
    # glcoud commands here
}"

```

For your particular case, your `gcloud` command could look like this:

```auto
sudo -u jupyter -g users bash -c "{
      gcloud storage cp --recursive "gs://fc-1111-111-1111-111111/module_data/module_1/part2" /home/jupyter/data
}"

```

Please note that the `--billing-project` flag may be needed for “Requester Pays” workspaces/buckets cases. More info here:

- [https://support.terra.bio/hc/en-us/articles/360029801491-Using-Requester-Pays-workspaces-buckets](https://support.terra.bio/hc/en-us/articles/360029801491-Using-Requester-Pays-workspaces-buckets)

---

<div class="post-metadata">

**Author:** ![camancuso](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@camancuso](https://help.anvilproject.org/u/camancuso)\
**Post date:** [May 30, 2025, 7:58pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/6 "2025-05-30T19:58:30Z")

</div>

This still didn’t work for me. Nothing was copied over. I didn’t set the billing project flag as it is not a Requester Pays workspace/bucket.

---

<div class="post-metadata">

**Author:** ![Javier-CP](https://yyz1.discourse-cdn.com/flex027/user_avatar/help.anvilproject.org/javier-cp/32/168_2.png) [@Javier-CP](https://help.anvilproject.org/u/Javier-CP)\
**Post date:** [June 2, 2025, 1:16pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/7 "2025-06-02T13:16:11Z")

</div>

@camancuso

If you haven’t done so, could you try the minimal example above for maybe just one file and let us know if that works for you? For example:

```auto
#!/bin/bash

sudo -u jupyter -g users bash -c "{
   gcloud storage cp gs://fc-1111-111-1111-111111/file .
}"

```

If possible, could you share the script you are having issues with?

---

<div class="post-metadata">

**Author:** ![camancuso](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@camancuso](https://help.anvilproject.org/u/camancuso)\
**Post date:** [June 2, 2025, 2:21pm UTC](https://help.anvilproject.org/t/gcloud-with-start-up-script-on-jupyter/304/8 "2025-06-02T14:21:57Z")

</div>

This works! It works for recursive copying as well. I think removing the quotes around the gs file name part is what did it. Thanks!
