Coder Social home page Coder Social logo

cask / cask Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 147.0 1.5 MB

Project management tool for Emacs

Home Page: http://cask.readthedocs.io

License: GNU General Public License v3.0

Makefile 4.34% Python 1.75% Shell 0.86% Emacs Lisp 88.02% Batchfile 0.06% Gherkin 4.98%

cask's Introduction

Cask

https://github.com/cask/cask/actions/workflows/test.yml/badge.svg

Cask can be likened to venv or maven for Emacs Lisp development, although, as with all things emacs, is decidedly less sophisticated (but no less arcane).

Cask provisions dependencies within a sandbox via a user-defined “Cask” file analogous to requirements-dev.txt or pom.xml.

Cask does not absolve you of having to learn emacs’s command flags. Cask only constructs the sandbox, one for each version of emacs you choose to test.

Installation

git clone https://github.com/cask/cask
make -C cask install

Not-so-quick start

With just this baseline “Cask” file, you can run most of the commands described in http://cask.readthedocs.io.

(source gnu)
(source melpa)

(package-file "your-main-file.el")

The EMACS environment variable governs which emacs binary to test. For example, the following runs ert tests under an older emacs:

EMACS=emacs-25.3 cask emacs --batch -l mytest.el -f ert-run-tests-batch

We have deprecated the cask exec invocation, and consequently no longer recommend cask exec ert-runner nor cask exec ecukes .

Typical Makefile Usage

Egregious boilerplate follows:

export EMACS ?= $(shell command -v emacs 2>/dev/null)
CASK_DIR := $(shell cask package-directory)

$(CASK_DIR): Cask
	cask install
	@touch $(CASK_DIR)

.PHONY: cask
cask: $(CASK_DIR)

.PHONY: compile
compile: cask
	cask emacs -batch -L . -L test \
          --eval "(setq byte-compile-error-on-warn t)" \
	  -f batch-byte-compile $$(cask files); \
	  (ret=$$? ; cask clean-elc && exit $$ret)

.PHONY: test
test: compile
	cask emacs --batch -L . -L test -l readme-test -f ert-run-tests-batch

Typical CI Usage

Cask, in conjunction with setup-emacs, is commonly used in Github Actions. Egregious boilerplate follows:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        emacs-version:
          - 26.3
          - 27.2
          - 28.2
          - 29.2
    steps:
      - uses: actions/checkout@v2
      - uses: purcell/setup-emacs@master
        with:
          version: ${{ matrix.emacs-version }}
      - uses: actions/cache@v2
        id: cache-cask-packages
        with:
          path: .cask
          key: cache-cask-packages-000
      - uses: actions/cache@v2
        id: cache-cask-executable
        with:
          path: ~/.cask
          key: cache-cask-executable-000
      - uses: cask/setup-cask@master
        if: steps.cache-cask-executable.outputs.cache-hit != 'true'
        with:
          version: snapshot
      - run: echo "$HOME/.cask/bin" >> $GITHUB_PATH

Frequently Asked Questions

Why does this shit never work?
Bitrot and weak hacks, primarily. Always try rm -rf ~/.emacs.d/.cask since we’re liable to make backwards-incompatible changes.
Why does this utterly fail on Windows?
If you use emacs on Windows, you’re not doing it right. But for a sufficiently motivated Powershell bro, it would not be hard to finesse the Makefile for a typical Windows environment.
Why does install “not know where to install”?
After assaying cross-platform schemes like systemd-path and XDG_DATA_HOME to figure out a suitable install directory, Cask resorts to the old, unspoken standbys of ~/.local/bin and ~/bin. If neither of those are present, then make install gives up with that error. I couldn’t determine a more standard method last I asked stackoverflow.com. To fix this error, you can manually specify the install directory like this - DESTDIR="$HOME/path/to/install/dir" make install.
Why is everything you say inconsistent with cask.readthedocs.io?
I would disregard nearly everything at cask.readthedocs.io, especially the Quickstart page. In particular, I would not require cask in your dot.emacs since cask is now largely a command-line tool independent of whatever you do within emacs. If you are calling cask-initialize in your dot.emacs or harken back to the bygone era of pallet, I’m afraid you’re on your own.
Doesn’t Cask make things more complicated?
Yes, because it forces you to test your package under multiple versions of emacs. Most packages don’t do any testing at all, which is why emacs has lost credibility with the computing public.

cask's People

Contributors

45mg avatar akirak avatar atykhonov avatar cniles avatar conao3 avatar cowboyd avatar dajva avatar davidshepherd7 avatar dickmao avatar dudebout avatar eflynn avatar eviltofu avatar fuco1 avatar immerrr avatar jcs090218 avatar jleechpe avatar jvshahid avatar kalifg avatar marsam avatar phillord avatar phillord-ncl avatar rejeep avatar sambrightman avatar snogge avatar swsnr avatar syohex avatar tarsius avatar tkf avatar wilfred avatar wyuenho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cask's Issues

Source alias

Add alias for most common sources:

(source "melpa" "http://melpa.milkbox.net/packages/")
(source "marmalade" "http://marmalade-repo.org/packages/")

vs.

(source 'melpa)
(source 'marmalade)

Multiple Emacs version support

It would be great if I can install packages for development against multiple Emacs versions. My idea is to use .carton/$EMACS/ directory instead of elpa/. Probably it's better to use version number instead of $EMACS as it can be full path to the Emacs executable.

Archives

Ideally we would be able to create a Cask.lock file with exact versions, but ELPA does not support multiple versions (madness I say). It's obviously really annoying that a bug in some other project can break my project when I install or update. So many times have I done an update to break my Emacs configuration without being able to go back and the only solution is to disable some plugin until the bug is fixed.

Here are a few solutions that makes things a little bit better.

  1. For each install and update, cask archives the current build with a date.
  2. As above, but only when the --archive option (a message could be used instead of a date)
  3. We add a command archive/stash/... that saves the current build with a message.

For all solutions, we would add a command apply/checkout/... that replaces the current build with the saved one.

Thoughts?

Default vs. alternate installation method

In the README, the recommended method to use Carton is:

(require 'package)
(setq package-user-dir
      (locate-user-emacs-file (format ".carton/%s/elpa/" emacs-version)))
(package-initialize)

and the alternate is:

(require 'carton "~/.carton/carton.el")
(carton-initialize)

There is a downside with the default, which is that the sources are not added. I still want to be able to install packages from within Emacs, mostly for trying it out before adding it to the Carton file.

Packages such as https://github.com/rdallasgray/pallet also need the source and for that it needs Carton, which in the primary method is not required.

Should we use the alternate version and not even include primary?

Package command

Add package command that build a tar file of files and docs.

spec

  • Usage: cask package
  • Use package-build.el

questions

  • Build package and save to dist directory. Add option to change this path.

Build command

Add build command that byte compiles the specified files.

spec

  • Usage: cask build
  • Byte compile all Elisp-files specified in the files directive
  • Move to build directory

questions

  • Should files specified in the files directive that are not Elisp files be moved to the build directory?

Root installation of Cask

Cask 0.4 does not longer work when installed as root, but used from a normal account, because it attempts to write to its installation directory during the bootstrap process.

I didn't think of this before, but now that I do, I don't like this. Programs should just not write to their installation directory, and Cask is no exception to the rule.

Instead of bootstrapping at $INSTALLDIR/.cask, we should rather bootstrap at $XDG_DATA_HOME/.cask, defaulting to $HOME/.local/share/.cask, in compliance with XDG Base Directory Spec.

In any case, we broke root installations. They used to work, but they don't work anymore now. So I'd like to make clear once and for all, whether we should actually support Cask being installed as root (or generally, system-wide as opposed to $HOME).

I think we definitely should, for various reasons, but YMMV. Opinions?

If we decide to support root installs, we should fix them asap. Basically, redirecting the bootstrap directory should be all that needs to be done.

Before releasing v0.4

This needs to be done before a v0.4 release:

  • Rename repository from rejeep/carton to rejeep/cask.el
  • Update MELPA recipe for Carton and create one for Cask (see https://github.com/rejeep/melpa/tree/cask)
  • Should we give folks a two days heads up on Twitter before releasing?
  • Notify Pallet about changes

Pretty output

Hide hideous (mostly package) output and only print our own. On fail, write to log for debugging.

Suggestions

A few suggestions.

Currently, writing an incorrect Cask file (missing paren, for example) gives a not very helpful message.

Plus, the new syntax (source melpa) is handy but the command (source "melpa") should also be valid as it is more consistent with other statements of the DSL.

What do you think?

Link command

Add link command (like npm link).

spec

  • Usage: cask link [package]
  • Without argument, add that package to list of packages that can be linked
  • With argument, link to the local package

questions

  • List links
  • Remove links
  • Name links

bin/cask fails to run from inside emacs shell

bin/cask uses $EMACS as the emacs executable if it is set. Inside an emacs shell EMACS is set to a string that is not the path for the emacs executable.

When I start an emacs shell or term, EMACS is set to 24.3.50.1 (term:0.96). According to the Emacs manual, EMACS should be set to t:

Emacs also sets the EMACS' environment variable tot' if it is not
already defined. Warning: This environment variable is deprecated.
Programs that check this variable should be changed to check
`INSIDE_EMACS' instead.

Could a different name be used for the variable that contains the path the emacs so that cask can work inside an emacs shell?

Upgrade command

Make a command to easily upgrade Cask and its dependencies.

Reduce noise originating from package.el (url.el actually)

Do you think anything can be done about noisy output like this in travis logs?:

Reading [application/x-tar]... 2k of 103k (2%)
Reading [application/x-tar]... 5k of 103k (5%)
Reading [application/x-tar]... 6k of 103k (6%)
Reading [application/x-tar]... 7k of 103k (7%)
Reading [application/x-tar]... 10k of 103k (10%)
Reading [application/x-tar]... 13k of 103k (13%)
Reading [application/x-tar]... 14k of 103k (14%)
Reading [application/x-tar]... 17k of 103k (17%)
Reading [application/x-tar]... 18k of 103k (18%)
Reading [application/x-tar]... 21k of 103k (21%)
Reading [application/x-tar]... 25k of 103k (25%)
Reading [application/x-tar]... 25k of 103k (25%)
Reading [application/x-tar]... 27k of 103k (26%)
Reading [application/x-tar]... 28k of 103k (28%)
Reading [application/x-tar]... 32k of 103k (31%)
Reading [application/x-tar]... 32k of 103k (32%)
Reading [application/x-tar]... 34k of 103k (33%)
Reading [application/x-tar]... 35k of 103k (34%)
Reading [application/x-tar]... 39k of 103k (38%)
Reading [application/x-tar]... 41k of 103k (40%)
Reading [application/x-tar]... 42k of 103k (41%)
Reading [application/x-tar]... 44k of 103k (43%)
Reading [application/x-tar]... 47k of 103k (45%)
Reading [application/x-tar]... 49k of 103k (48%)
Reading [application/x-tar]... 51k of 103k (49%)
Reading [application/x-tar]... 52k of 103k (51%)
Reading [application/x-tar]... 55k of 103k (53%)
Reading [application/x-tar]... 56k of 103k (55%)
Reading [application/x-tar]... 59k of 103k (58%)
Reading [application/x-tar]... 61k of 103k (59%)
Reading [application/x-tar]... 65k of 103k (63%)
Reading [application/x-tar]... 66k of 103k (64%)
Reading [application/x-tar]... 68k of 103k (66%)
Reading [application/x-tar]... 71k of 103k (68%)
Reading [application/x-tar]... 72k of 103k (70%)
Reading [application/x-tar]... 76k of 103k (74%)
Reading [application/x-tar]... 78k of 103k (75%)
Reading [application/x-tar]... 82k of 103k (79%)
Reading [application/x-tar]... 82k of 103k (79%)
Reading [application/x-tar]... 83k of 103k (81%)
Reading [application/x-tar]... 85k of 103k (82%)
Reading [application/x-tar]... 86k of 103k (83%)
Reading [application/x-tar]... 88k of 103k (85%)
Reading [application/x-tar]... 89k of 103k (86%)
Reading [application/x-tar]... 92k of 103k (89%)
Reading [application/x-tar]... 93k of 103k (90%)
Reading [application/x-tar]... 96k of 103k (93%)
Reading [application/x-tar]... 97k of 103k (94%)
Reading [application/x-tar]... 99k of 103k (96%)
Reading [application/x-tar]... 102k of 103k (98%)
Reading [application/x-tar]... 103k of 103k (100%)
Reading... done.
Wrote /home/travis/build/tarsius/emacs-plugin-template/elpa/ert-0/ert.el
Wrote /home/travis/build/tarsius/emacs-plugin-template/elpa/ert-0/ert-pkg.el

emacs23 cannot find package.el

Hey there!

Thanks for the great emacs package manager! Just what I was looking for :3 Excited to continue to use it as I rewrite my dotfiles from scratch :)

After installing, I noticed that my version of emacs was complaining about a missing package.el (which I've read is built into emacs24). Attempting to run carton commands resulted in the following:

Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Cannot open load file: package

I suspect that this was because running carton was doing so through the emacs batch mode, which was not loading my personal emacs configuration (~/.emacs nor ~/.emacs.d/init.el)

I resolved this by running adding a --user option to the batch command, which apparently loads my emacs configuration :P

I'll attach a corresponding pull request shortly, though the solution does feel a bit brittle; just a quick fix so that I can continue fixing my emacs config :)

Show update packages

When running carton update, when done, show list of updated packages and their new (and old) version.

make compile

Add make compile task which is a part of the test suite. This is to make sure there are no compilation warnings/errors.

Naming problem

There has been already a tool named carton and it provides features like Bundler to Perl.

carton has been widely used in Perl community, of course including Emacs users like me ;), so it'll be happy to everyone if you change the name of this tool.

https://metacpan.org/release/carton

Make carton available in a package repo.

I'd like to do some development based on carton, but I would need it to be available via Emacs' package system. Is there any reason why it's not (I'm guessing this might be to do with the presence of the binary carton command)?

Docs directive

Add doc/docs directive.

spec

  • Usage: (doc &rest files) or (docs &rest files)

questions

  • Should doc/docs be default path for documentation?

What package isn't found?

During a carton, I get this:

Contacting host: melpa.milkbox.net:80
Error during download request: Not Found

It doesn't say what package isn't found, however. I guess it tries to download dependencies in order, and that I can then decipher which package was install prior by deciphering the output of the compilation, but it would be very nice to know up front what packages are being fetched. Maybe just a header printed out "Downloading dash 1.3.2" or something. :)

Travis CI

Add Travis CI support. I'm thinking something like this:

carton travis [options]

Update ZSH completion

This is just a reminder to update the ZSH completion with newly added commands before releasing v0.4.

Cask outdated

Add outdated command that show list of outdated packages.

Add elpa.gnu.org if Emacs-23?

From http://melpa.milkbox.net/. Something we need to take care of?

In Emacs < 24, you'll also need to explicitly include the GNU ELPA archive, which provides important compatibility libraries like cl-lib:

(when (< emacs-major-version 24)
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))

New directives and commands

Let's discuss the new directives and commands that should be added to make Cask useful as a project management tool instead of a dependency management tool (see #82). When we all agree, we create one issue per directive/command and add to the 0.6 milestone.

Commands

  • build - byte compile project
  • doc - create documentation
  • test - run tests
  • link - link to local package (see #25)
  • package - create tar package of project, including documentation

Directives

  • files - list of files to include in build
  • docs - list of doc files

v0.4 WIP

List features and changes in v0.4

  • Install packages under .carton/elpa/EMACS-VERSION
    See (pull request) #40 and (issue) #31
    Assigned: @tkf
  • Rename project
    See #20
    Assigned: none
  • Rewrite bin/carton in Emacs Lisp
    See #24
    Assigned: @rejeep
  • Add .carton/elpa/EMACS-VERSION/package/bin to PATH for carton exec.
    See #32
    Assigned: @rejeep

CI ensuring byte-compile and melpa receipe works too

In my CI scripts today, Cask fetches all dependencies from melpa. However, the package under test is run from the checked out source code.

Now, sometimes thing break in byte compilation. Other times the melpa receipe is wrong. This results in green CI, and failing package installs.

What I would like to accomplish is this:

  • instead of running the tests on the checked out source code, use the melpa receipe to build a package file.
  • use that to run the tests.

This way we get to check both byte compilation and melpa receipe in CI.

Now, I'm not sure if this belongs in Cask. Or in Melpa. Or someplace else entirely. But it would certainly have avoided yesterdays nasty business (melpa/melpa#957)

Hooks

See #83

Add support for hooks. This basically means that another package should be able to hook in to Cask.

A concrete example of this is the cask test command (not yet implemented), which should run tests, but Cask should not know of any specific test frameworks. Instead, the testing framework should add a testing hook which will register what to do when running tests for that framework.

bin/carton in Emacs Lisp

The branch bin-carton-in-emacs-lisp is slowly shaping up. It would be awesome if someone else could take a look (ping @tkf, @lunaryorn). There are most likely a few issues I have not found myself, but I could use some help finding them.

@lunaryorn I noticed that the Ecukes tests do not pass for snapshot (see https://travis-ci.org/rejeep/carton/jobs/8474140). I think you mentioned you are running snapshot. It would be awesome if you could take a look at it. I'll try to install it myself and see as well.

Related issues:
Windows support
Carton bootstrap dependencies

Files directive

Add files directive.

spec

  • Usage: (files &rest patterns)
  • Support f-glob patterns

questions

  • Include files by default:
    • bin/*
    • *.el
    • templates/*.tpl

Doc command and directive

Add doc command and directive that generates documentation.

spec

  • Use files directive
  • Command usage: cask doc or cask docs
  • Build documentation to doc or docs folder

questions

  • Should it be possible to change doc directory?
  • What kind of documentation should be supported?

Test command

Add test command that runs all tests. This command requires hooks (see #84). A testing framework (ecukes, ert-runner) can then add a test hook so that when the cask test command runs, the tests runs.

spec

  • Usage: Run tests on files interpreted cask test [args]
  • Usage: Run tests on files compiled cask test [args] --build
  • Usage: Run tests on built package cask test [args] --package

questions

EPL must handle multiple available packages

It just came to my attention, that Emacs snapshot tracks all versions of a package across all archives. However, EPL ignores any but the most recent package.

In and by itself that's no problem, because package.el returns the most recent package front up, hence updates incidentally work well, hence labeled as “enhancement”, and not assigned to 0.4 milestone.

epl-find-available-package should be renamed to epl-find-available-packages, and return a list of all packages for the given name, by version number in descending order. The legacy EPL would just return a list containing the single available package.

Primarily a reminder to myself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.