# Need help adding /scratch shortcut to files menu

**URL:** <https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979>\
**Category:** Get Help\
**Created:** [January 22, 2025, 8:12pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979 "2025-01-22T20:12:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 22, 2025, 8:12pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/1 "2025-01-22T20:12:05Z")

</div>

Hello, we could use a bit of help adding a /scratch shortcut to our files menu. None of us know the first thing about Ruby so I apologize for what may be a pretty novice question for others.

We’ve tried the examples listed here and haven’t had much luck: [Customizations — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/customizations.html#add-shortcuts-to-files-menu). Basically, every time we try to implement one of the examples or make changes to one of the examples, nothing shows up underneath our Files menus. Just the home directory by default.

Basically, our /scratch folders are set up as follows:

/scratch/domain1/username  
/scratch/domain2/username  
/scratch/domain3/username

We have several domains accessing our OOD site, and each scratch directory is grouped by that user’s domain, then the user’s scratch folder is under their respective domain

I don’t know if this complicates things, but technically, when a user signs in, their login name shows up as username@domain1.local. Their scratch directory in their respective subfolder just says ‘username’ and username@domain1.local owns it. I don’t know if we’re running into an issue where OOD sees the username differently from what their scratch directory is actually named, and that’s why nothing shows up?

Any direction on this would be greatly appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 22, 2025, 8:40pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/2 "2025-01-22T20:40:34Z")

</div>

Can you share the initializer you’re using that’s not working for you?

---

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 23, 2025, 1:44pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/3 "2025-01-23T13:44:55Z")

</div>

Jeff, this is what we were using on our old cluster that worked previously, though we only had one domain.

```auto
# /etc/ood/config/apps/dashboard/initializers/ood.rb

OodFilesApp.candidate_favorite_paths.tap do |paths|
paths << FavoritePath.new("/scratch/domain1/#{User.new.name}")
end

```

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 23, 2025, 3:58pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/4 "2025-01-23T15:58:19Z")

</div>

Seems like you need to find the domain name (i.e., domain1 or domain2) first.

If you run this program, does the output contain your domain?

```ruby
require 'etc'

login = Etc.getlogin
puts Etc.getpwnam(login).inspect

```

Here’s an example of me running this program. Here my `name` field doesn’t have a domain, but I’m guessing it could on your side.

```shell
[johrstrom ~()] 🐺 ruby delme.rb 
#<struct Etc::Passwd name="johrstrom", passwd="*", uid=30961, gid=5515, gecos="Jeff Ohrstrom", dir="/users/PZS0714/johrstrom", shell="/bin/bash">

```

---

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 23, 2025, 4:22pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/5 "2025-01-23T16:22:10Z")

</div>

Thanks Jeff, yes, it does contain a username on the end i.e. username@domain.local. Is there an easy way to script it to drop the domain.local so it finds that user’s scratch directory without it?

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 23, 2025, 4:38pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/6 "2025-01-23T16:38:50Z")

</div>

Yea here’s how you can do that, you can call `split` on the string. Here’s a little program I made to demonstrate this. IDK if you want `domain1` in the scratch path or `domain1.local` so I’ve given both here.

```ruby
require 'etc'

# login should be Etc.getlogin
login = 'johrstrom@domain1.local'
basename, domain = login.split('@')

puts "/scratch/#{domain}/#{basename}"

# you want domain1 not 'domain1.local'
no_local_domain = domain.split('.').first

puts "/scratch/#{no_local_domain}/#{basename}"

```

---

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 23, 2025, 5:56pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/7 "2025-01-23T17:56:59Z")

</div>

Jeff, thank you! That’s really helpful. The top part of the script returns what it should. However, we still don’t see the /scratch directory showing up in the files menu in OOD. Do we need to have the initializer set up like this for instance? We tried the top part of the script you sent as well, and that didn’t work either. Trying to figure out what we might be missing.

```auto
require 'etc'

login = Etc.getlogin
basename, domain = login.split('@')

Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|
    # add User scratch space directory
    paths << FavoritePath.new("/scratch/#{domain}/#{basename}")
    puts #{paths}
  end
end

```

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 23, 2025, 6:03pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/8 "2025-01-23T18:03:02Z")

</div>

We filter this list based on this expression. Do you have allowlists set and is `/scratch` allowed?

Other than that, it appears the path has to be a readable and executable directory. If any of these are false, it won’t show up in the list.

> <https://github.com/OSC/ondemand/blob/1a685ab85ba2b228dd91e4c703fa9abbeb43923a/apps/dashboard/app/apps/ood_files_app.rb#L26>

---

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 23, 2025, 6:33pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/9 "2025-01-23T18:33:50Z")

</div>

Jeff, that’s interesting. We aren’t using allowlists (left everything there default) so everything should be accessible. And, user scratch directories are readable/executable. I can log in to the OOD node and navigate to my /scratch directory via the command line. I’m restarting the web server every time I make a change. If there’s nothing else that could potentially be affecting this, we can continue to chip away at it on our side.

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 23, 2025, 6:52pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/10 "2025-01-23T18:52:45Z")

</div>

Maybe you can redefine that method to see some debug logs. You can try something like this and name it `00_fav_paths.rb` because these run in order, so this will run before `ood.rb`.

This will spit out what the list is before filtering and detail if you’re keeping the path.

```ruby

Rails.application.config.after_initialize do
  class OodFilesApp
    def favorite_paths
      Rails.logger.info("favorite paths are currently: #{candidate_favorite_paths.inspect}")
      @favorite_paths ||= candidate_favorite_paths.select do |p|
        if p.remote?
          true
        else
          keep = AllowlistPolicy.default.permitted?(p.path) && p.path.directory? && p.path.readable? && p.path.executable?
          Rails.logger.info("Keeping #{p}? #{keep}")
          keep
        end
      end
    end
  end
end

```

---

<div class="post-metadata">

**Author:** ![rgas20](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rgas20/32/309_2.png) [@rgas20](https://discourse.openondemand.org/u/rgas20)\
**Post date:** [January 24, 2025, 2:13pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/11 "2025-01-24T14:13:17Z")

</div>

Thanks again Jeff! It’s working now - silly NFS config issue we overlooking. This is going to improve the user experience for sure. I really appreciate the example and your willingness to help us out with this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [July 23, 2025, 2:13pm UTC](https://discourse.openondemand.org/t/need-help-adding-scratch-shortcut-to-files-menu/3979/12 "2025-07-23T14:13:27Z")

</div>

Closed on July 23, 2025, 2:13pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
