Toggling package on install and start - atom-editor

I'm trying to figure out how to get my Atom package I'm building to toggle on install and editor start. I'm not sure what to put into the activate function. At the moment you install my package then have to toggle in the command palette. Is there a way to avoid this and to just have Atom toggle the package automatically when installed/enabled

Atom uses the activationCommands entry in the package.json to declare that activation of the package can wait until one of the listed commands is executed. If this entry does not exist, then the package will be activated immediately after it is loaded (which is on installation or application start).
The reason why activationCommands is highly recommended is that not all packages need to be activated immediately after loading and it is a simple way to reduce Atom's startup time. You can check Atom's startup time with the timecop package by pressing Shift+Cmd+P on OS X to open the Command Palette and search for timecop.

Related

Prevent R from executing code in R profile when installing packages

I have some code in my R profile that I've found interferes with package installation. For example, I like to automatically load devtools when I'm working on packages, so I have this
if (file.exists("DESCRIPTION")) {
try({suppressMessages(library(devtools))})
}
However, I've found that this interferes with package installation, I get errors like ERROR: lazy loading failed for package ‘rlang’. If I comment out the loading of devtools in the R profile, the package installs without error.
Is there any way to check if .Rprofile is being executed during package installation so that I could put that condition in the if and stop devtools from loading at inappropriate times?
I’d generally recommend against putting such code into your ~/.Rprofile! — The ~/.Rprofile should contain only general configuration that is always valid. For further customisation, use a project-local ~/.Rprofile instead.
However, I would make one exception to the above guideline, because one useful distinction you can make is to only execute certain code in interactive sessions:
if (interactive()) {
if (file.exists("DESCRIPTION")) {
try({suppressMessages(library(devtools))})
}
}
.Rprofile files are sourced on R startup. They won't be called later by other functions so you can't use the checking logic during install.packages().
For this reason loading packages using RProfile is not always advisable as it can make your code non-reproducible. However, as a helper package, devtools is probably a good exception (ignoring your particular problem here).
If you use base R only you can tell R not to load Rprofile during startup by using the --vanilla or --no-init-file arguments.
If you are using RStudio one workaround would be to use project level Rprofile files. Rstudio starts a new R session for each project, and loads the user Rprofile from the project root. If it then can't find that it will attempt to load the user RProfile.
Create a new project and within the the project options tick the option to disable the Rprofile loading.
Whenever you want to install a package switch to this project.
One caveat is to make sure you are running this as the only project session open, having multiple RStudio sessions open when installing new packages can lead to problems without putting the Rprofile in the mix.
Rstudio article on startup files https://support.rstudio.com/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf
Base R documentation on R initialization https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
A diagram of the R startup flow and some commentary on use of renviron and rprofile
https://rstats.wtf/r-startup.html

Julia: How to deal with ERROR: Unsatisfiable requirements detected for package?

When I install packages, I sometimes encounter this error. What is the issue and how to resolve it?
Learn how to use the ]activate command.
Just create a new directory somewhere, e.g. c:/a_new_directory then activate
]activate c:/a_new_directory
Once activated, you can install whatever packages you need since it's a fresh environment.
Every time you want to use the same set of packages together, just activate that directory.
Try not to install everything using add try to do activate before add.

Submitting a pull request for a Julia package in Pkg v1.1

I want to add a feature to FITSIO package and submit a pull request. What is the current workflow for that? Before Pkg 1.0 there were Pkg.checkout and Pkg.submit functions. Are there similar commands that I can run in Pkg v1.1?
Of course, I can manually fork the repository on Github, make changes and submit a pull request. But I wonder if there are convenient shortcuts in Pkg 1.1 for that?
Update
Here is a useful guide that I found.
You can use Pkg.develop (or the develop Pkg REPL command) which will download a full git-clone of the package and put it in $HOME/.julia/dev by default. There you can make your changes and push as usual.
Pkg.develop can also take a path as an argument, so if you have git cloned the repository to some other more convenient folder (as compared to $HOME/.julia/dev) and prefer to work there you can "install" that path by Pkg.develop(PackageSpec(path = "path/to/clone")) and it should be available to load from within Julia.
EDIT:
checkout has been replaced by two new things:
if the intention is just to install the master branch of the package you now do pkg> add Example#master (or Pkg.add(PackageSpec(name="Example", rev="master")));
If the intention is to modify the code you use Pkg.develop.
There does not exist something like Pkg.submit in the new package manager; you have to git push and make a PR yourself.

How to update to Julia 0.7 on MacOs without installing packages again

I am a user of Julia v0.6, no issues to report. I am trying to update to Julia v0.7. I already have the CMD line version installed.
I copied the packages over from the v0.6 folder into my packages folder that came with v0.7.
Here is an image of my file structure in finder.
I see the packages in the "Packages" folder you see above. However, when I try "using SHERPA" for example(SHERPA is a package in the "Packages" folder), it says it's not installed. I thought maybe Pkg.init() would fix the problem but that command is deprecated on v0.7 so I don't know what to do.
I have already looked at the other StackOverflow questions and those didn't resolve my issue. I also already tried Pkg.resolve() and Pkg.Update() to no avail.
I appreciate your support.
Edit W/Solution:
At the time of this writing, I am running MacOs Mojave on my Mac and would suggest at least MacOs High Sierra since the file structure was changed in there.
Install Julia 0.7: https://julialang.org/downloads/ Note: if you don't see v0.7 on the link above, go here: https://julialang.org/downloads/oldreleases.html
Once v0.7 is installed, make sure it dragged into your application folder.
Run the program. Type "Pkg.resolve()" and "Pkg.Update()" in the Julia Terminal window that appears.
Then Run:
Pkg.add("JSON")
in order to get your packages file to show up...
This should make it so the new package management system is enabled. You can confirm that by checking your ".julia" folder(which can be accessed but going to finder - clicking Command-Shift-H and then Command-Shift-.)
You should see an "environments", "packages" and "registries" folder(in addition to probably a few others). Note as of now, due to the new package manager, you either cannot or I don't know how to, clone a project from GitHub desktop to your packages folder.
To add a custom-made package: open command line version v0.7
Type "]". You should see "(v0.7) pkg> " in blue text. Note use "Control"-"c" to exit Pkg mode in terminal.
Type " add https://github.com/xxxxxxx/xxxxxxx.git"
Type " add https://github.com/xxxxxx/xxxxxxx.git" Note: follow any on-screen prompts(i.e. "Type PKg.resolve() or Pkg.update()")
Note: you will probably see many depreciation warning when you run your old code.
How to use the new Pkg manager in Julia v0.7: https://docs.julialang.org/en/v1/stdlib/Pkg/index.html
This is not possible and/or not recommended for the following reasons:
The package manager is completely new in Julia v0.7/v1.0 compared to the one in Julia v0.6. In particular, the new package manager does not understand the old package managers folder structure and method of installation (git cloning). As a sidenote, the packages folder is not supposed to be modified by users, it is controlled by Pkg, and, in particular, putting something in the packages folder does not mean it is installed.
Since there have been very many changes between Julia v0.6 and v0.7/v1.0 is is unlikely that the same package versions that you use on Julia v0.6 works on newer Julia versions, so you don't really gain anything from copying, since you need to "reinstall" new versions anyway.
I would also like to point out that the new package manager is much faster compared to the old one, so
pkg> add PackageA PackageB ...
to add all the packages you use should not take more than a minute.

Package Control: Install Package File "<string>", line 1 Package Control: Install Package ^ SyntaxError: invalid syntax

I'm trying to install Emmet to Sublime as a plugin.
I open the console, and paste in
Package Control: Install Package
as instructed on the Emmet page.
However, when I hit enter I get
>>> Package Control: Install Package
File "<string>", line 1
Package Control: Install Package
^
SyntaxError: invalid syntax
Does anyone know why this happening and perhaps how to circumvent it?
First, you need to ensure that you have Package Control installed. Check here for instructions.
Once Package Control is installed and you've restarted Sublime, you need to open the Command Palette, not the console. You can use Tools -> Command Palette, or use the keyboard shortcut (CtrlShiftP on Windows and Linux, ⌘ShiftP on OS X). The Command Palette uses a fuzzy search algorithm, so you can either paste in the entire string Package Control: Install Package, or just type pci and it will come up. Hit Enter once it's highlighted, type in emmet, hit Enter again, and it will install. Please keep in mind that you need to have git installed on your system and in your PATH in order for Package Control to work properly.
I would also add my answer as it might be helpful for some future newbies to sublime.
When I would type ctrl + shift + p in Sublime I would get a screen capture instead of command line of an editor.
In order to change that I needed to go to the SnagIt properties to change its hot keys to make a screen capture on Ctrl+shift+alt+p
After that I was able to call the command line in Sublime editor and install Emmet accordingly.

Resources