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

Sourced functions within job don't work with objects defined out of function #5178

Closed
MiksLynx opened this issue Aug 5, 2019 · 2 comments
Closed

Comments

@MiksLynx
Copy link

MiksLynx commented Aug 5, 2019

System details

RStudio Edition : Desktop
RStudio Version : 1.2.1335
OS Version      : Windows Server 2016 Standard
R Version       : 3.5.0

Steps to reproduce the problem

  1. Save this code in functions.R
customFunction <- function(first, second) {
  first + second
}

customFunction2 <- function(first, second) {
  first + second + d
}
  1. Run this code as a separate job
a <- c(1,2)

b <- c(3,4)

d <- c(100, 100)
source('functions.R')

xx <- customFunction(a, b)

yy <- customFunction2(a, b)

Describe the problem in detail

The job fails with error message:

Error in customFunction2(a, b) : object 'd' not found
Calls: sourceWithProgress -> eval -> eval -> customFunction2
Execution halted

Describe the behavior you expected

I expected the job to run without errors. I suppose the problem is within the fact that

  1. Object d is not a parameter of function customFunction2();
  2. Functions are sourced from different .R file.

I understand that not defining d as a parameter in function is not the correct way of programming, but the question is if this is the way that Jobs are supposed to work?

@ronblum
Copy link
Contributor

ronblum commented Aug 5, 2019

@MiksLynx Thank you for raising this. We'll review this as we continue development of RStudio.

Reproducible in RStudio Desktop on MacOS 10.15 (Catalina).

@jmcphers
Copy link
Member

jmcphers commented Aug 5, 2019

This issue is currently tracked in #4586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants