Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change active here() directory #19

Closed
robertamezquita opened this issue Apr 3, 2018 · 8 comments · Fixed by #55
Closed

Change active here() directory #19

robertamezquita opened this issue Apr 3, 2018 · 8 comments · Fixed by #55

Comments

@robertamezquita
Copy link

robertamezquita commented Apr 3, 2018

Currently doesn't seem to change the here() output when changing directories - which is fine by design, however, if you need to change folders/projects there's no way to force a change in the here() reference.

here()  # outputs: /path/to/project_root
setwd('path/to/new_project_root')
here()  # still outputs: /path/to/project_root

## proposed:
change_here('/path/to/new_project_root')
here()  # outputs: /path/to/new_project_root

Might there be room for a change_here() function that forces a change in directory or something similar? (I'd prefer a reference to Oasis' "Be Here Now" but that might be too long).

@malaybasu
Copy link

Yes. This is an issue where working on multiple projects at the same time in the R studio. I am searching for a solution.

@krlmlr
Copy link
Member

krlmlr commented Apr 23, 2018

I have a separate .Rproj file for each project, and just open that when I want to switch projects. (Usually I also have more than one RStudio instance open at any given time.)

Restarting the R session also might work.

I'd like to keep the interface of here as simple as possible.

@leungi
Copy link

leungi commented Apr 15, 2019

I second this request, mainly to workaround a well-documented issue with RStudio running slow in network drive vs. local.

Currently, I set up .Rproj locally, while accessing everything else (e.g., scripts, data) from network. It really improves RStudio run time significantly.

Hope @krlmlr will consider.

Thanks!

@StevenHibble
Copy link

StevenHibble commented Aug 14, 2019

Here's my (hacky) workaround. Not sure if this breaks anything, but it seems good so far.

change_here <- function(new_path){
  new_root <- here:::.root_env
  
  new_root$f <- function(...){file.path(new_path, ...)}
  
  assignInNamespace(".root_env", new_root, ns = "here")
}

StevenHibble added a commit to StevenHibble/here that referenced this issue Nov 20, 2019
@krlmlr
Copy link
Member

krlmlr commented Nov 12, 2020

I'm hesitant to provide a supported entry point, there are other good reasons to start afresh. I documented a workaround that features unloadNamespace() in the "Getting started" article, feedback welcome.

@krlmlr
Copy link
Member

krlmlr commented Nov 15, 2020

here::i_am() offers a new way to declare the project root, each script and report declares its own path relative to the project root. Does this help with your scenario?

Read more at: https://here.r-lib.org/articles/here.html#declare-the-location-of-the-current-script-1

@leungi
Copy link

leungi commented Nov 15, 2020

here::i_am() offers a new way to declare the project root, each script and report declares its own path relative to the project root. Does this help with your scenario?

Read more at: https://here.r-lib.org/articles/here.html#declare-the-location-of-the-current-script-1

Thanks for this @krlmlr .

Hope you don't take this negatively, but it doesn't help my use case 😅.

The framework I have in mind is as follow:

  • allow .Rproj to be defined anywhere (in my case, local drive vs. network drive to improve RStudio IDE performance)
  • allow access to folders and files in network drive, via a link generated via a function in here

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants