{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/reprex/issues/204","repository_url":"https://api.github.com/repos/tidyverse/reprex","labels_url":"https://api.github.com/repos/tidyverse/reprex/issues/204/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/reprex/issues/204/comments","events_url":"https://api.github.com/repos/tidyverse/reprex/issues/204/events","html_url":"https://github.com/tidyverse/reprex/issues/204","id":359889995,"node_id":"MDU6SXNzdWUzNTk4ODk5OTU=","number":204,"title":"`utils::file.edit()` silently fails in `reprex()` when `reprex()` is run in an RStudio session on Windows","user":{"login":"crew102","id":11220793,"node_id":"MDQ6VXNlcjExMjIwNzkz","avatar_url":"https://avatars2.githubusercontent.com/u/11220793?v=4","gravatar_id":"","url":"https://api.github.com/users/crew102","html_url":"https://github.com/crew102","followers_url":"https://api.github.com/users/crew102/followers","following_url":"https://api.github.com/users/crew102/following{/other_user}","gists_url":"https://api.github.com/users/crew102/gists{/gist_id}","starred_url":"https://api.github.com/users/crew102/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crew102/subscriptions","organizations_url":"https://api.github.com/users/crew102/orgs","repos_url":"https://api.github.com/users/crew102/repos","events_url":"https://api.github.com/users/crew102/events{/privacy}","received_events_url":"https://api.github.com/users/crew102/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-09-13T13:13:17Z","updated_at":"2018-09-28T13:05:27Z","closed_at":null,"author_association":"NONE","body":"* Issue related to line https://github.com/tidyverse/reprex/blob/8c64e133ac7050bad02151cfb511c138e0a6c30d/R/reprex.R#L377\r\n\r\n* This issue may have gone unnoticed thus far b/c `utils::file.edit()` is wrapped in `defer()` and `defer()` seems to muffle errors (CC'ing @kevinushey, as I'm not sure if this is desired behavior):\r\n\r\n``` r\r\nlibrary(withr)\r\nfo <- function() {\r\n  defer({\r\n    print(\"printing\")\r\n    stop(\"stoping\")\r\n  })\r\n}\r\nfo()\r\n#> [1] \"printing\"\r\n```\r\n\r\nCreated on 2018-09-13 by the [reprex package](https://reprex.tidyverse.org) (v0.2.0.9000).\r\n\r\n* If `reprex()` didn't wrap `utils::file.edit()` in `defer()`, the user would see the following error to explain why no file had been opened: \r\n\r\n```r\r\nsome_file <- tempfile()\r\nutils::file.edit(some_file)\r\n#> Error in editor(file = file, title = title) : \r\n#>  argument \"name\" is missing, with no default\r\n```\r\n\r\nI believe this error stems from the fact that RStudio sets the \"editor\" option to be the following function on Windows:\r\n\r\nhttps://github.com/rstudio/rstudio/blob/8af730409bb6d651cc8f6816d136bea91441e7a4/src/cpp/session/modules/SessionEnvironment.R#L379\r\n\r\n.. but this function doesn't seem to play well with `utils::file.edit()` (it does work with RStudio's `file.edit()` though).\r\n\r\n* Relevant info on the platform on which `reprex()` fails to open file:\r\n\r\nR version: 3.4.4 (2018-03-15)\r\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\r\nRunning under: Windows 7 x64 (build 7601) Service Pack 1\r\nRStudio version: 1.1.419\r\n\r\n* PR on the way\r\n"},"comment":{"url":"https://api.github.com/repos/tidyverse/reprex/issues/comments/425429337","html_url":"https://github.com/tidyverse/reprex/issues/204#issuecomment-425429337","issue_url":"https://api.github.com/repos/tidyverse/reprex/issues/204","id":425429337,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTQyOTMzNw==","user":{"login":"krlmlr","id":1741643,"node_id":"MDQ6VXNlcjE3NDE2NDM=","avatar_url":"https://avatars0.githubusercontent.com/u/1741643?v=4","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"created_at":"2018-09-28T13:05:27Z","updated_at":"2018-09-28T13:05:27Z","author_association":"MEMBER","body":"Much of this appears very similar to `utils::View()`, and `tibble::view()` that builds around it. I have started [_tidyview_](https://github.com/krlmlr/tidyview) for a more robust `view()`, but the next version of _tibble_ will include a very simple `view()` function.\r\n\r\nPerhaps a robust implementation of `file_edit()` could be part of _tidyview_ at some point?"}}
{"actor":{"display_login":"krlmlr"}}