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

Version 1.0 breaks relative path #679

Closed
layik opened this issue Sep 23, 2020 · 2 comments
Closed

Version 1.0 breaks relative path #679

layik opened this issue Sep 23, 2020 · 2 comments

Comments

@layik
Copy link

layik commented Sep 23, 2020

System details

``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.2 (2020-06-22) #> os macOS Catalina 10.15.5 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_GB.UTF-8 #> ctype en_GB.UTF-8 #> tz Europe/London #> date 2020-09-23 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2) #> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2) #> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.1) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2) #> glue 1.4.1 2020-05-13 [1] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.2) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2) #> knitr 1.29 2020-06-23 [1] CRAN (R 4.0.2) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2) #> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2) #> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2) #> withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.2) #> xfun 0.16 2020-07-24 [1] CRAN (R 4.0.2) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2) #> #> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library ```

Created on 2020-09-23 by the reprex package (v0.3.0)

Example application or steps to reproduce the problem

Directory structure:

- R
-- plumber.R
- build
-- js
-- css
etc

Serve a build from a tag like

#' @assets ./build /
list()

using

# working dir here is parent of `R` in next line where `build` above is.
pr = plumber::plumb(file.path("R", "plumber.R"))
pr$run(port = 8000)

Describe the problem in detail

This used to work fine in 0.4.* but now broken in 1.0.0. as I believe the relative path in here is no longer doing what it used to do in 0.4.

I have a working fix but not sure if this is meant to be expecting a relative path to the "plumber" file or just session working directory. If latter, which used to be the case, then I think my PR would take care of it.

Happy to listen before I send a PR.

@meztez
Copy link
Collaborator

meztez commented Sep 23, 2020

First item in breaking changes : https://www.rplumber.io/news/index.html#breaking-changes

When plumb()ing a file (or Plumber$new(file)), the working directory is set to the file’s directory before parsing the file. When running the Plumber API, the working directory will be set to file’s directory before running.(#631)

From

old_wd <- setwd(dirname(file))

Sorry for the inconvenience, this is a more consistent behavior so that your plumber file is not dependent on your current working directory.

@layik
Copy link
Author

layik commented Sep 23, 2020

Oh, I thought I read those breaking changes. Thanks @meztez.

@layik layik closed this as completed Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants