Code Monkey home page Code Monkey logo

laptop's Introduction

Laptop

Laptop is a script to set up a macOS laptop for web and mobile development.

It can be run multiple times on the same machine safely. It installs, upgrades, or skips packages based on what is already installed on the machine.

Requirements

We support:

  • macOS Sonoma (14.x) on Apple Silicon and Intel
  • macOS Ventura (13.x) on Apple Silicon and Intel
  • macOS Monterey (12.x) on Apple Silicon and Intel

Older versions may work but aren't regularly tested. Bug reports for older versions are welcome.

Install

Download the script:

curl --remote-name https://raw.githubusercontent.com/thoughtbot/laptop/main/mac

Review the script (avoid running scripts you haven't read!):

less mac

Execute the downloaded script:

sh mac 2>&1 | tee ~/laptop.log

Optionally, review the log:

less ~/laptop.log

Optionally, install thoughtbot/dotfiles.

Debugging

Your last Laptop run will be saved to ~/laptop.log. Read through it to see if you can debug the issue yourself. If not, copy the lines where the script failed into a new GitHub Issue for us. Or, attach the whole log file as an attachment.

What it sets up

macOS tools:

  • Homebrew for managing operating system libraries.

Unix tools:

  • Universal Ctags for indexing files for vim tab completion
  • Git for version control
  • OpenSSL for Transport Layer Security (TLS)
  • RCM for managing company and personal dotfiles
  • The Silver Searcher for finding things in files
  • Tmux for saving project state and switching between projects
  • Watchman for watching for filesystem events
  • Zsh as your shell

Heroku tools:

GitHub tools:

Image tools:

Programming languages, package managers, and configuration:

  • asdf-vm for managing programming language versions
  • Bundler for managing Ruby libraries
  • Node.js and npm, for running apps and installing JavaScript packages
  • Ruby stable for writing general-purpose code
  • Yarn for managing JavaScript packages
  • Rosetta 2 for running tools that are not supported in Apple silicon processors

Databases:

  • Postgres for storing relational data
  • Redis for storing key-value data

It should take less than 15 minutes to install (depends on your machine).

Customize in ~/.laptop.local

Your ~/.laptop.local is run at the end of the Laptop script. Put your customizations there. For example:

#!/bin/sh

brew bundle --file=- <<EOF
brew "Caskroom/cask/dockertoolbox"
brew "go"
brew "ngrok"
brew "watch"
EOF

default_docker_machine() {
  docker-machine ls | grep -Fq "default"
}

if ! default_docker_machine; then
  docker-machine create --driver virtualbox default
fi

default_docker_machine_running() {
  default_docker_machine | grep -Fq "Running"
}

if ! default_docker_machine_running; then
  docker-machine start default
fi

fancy_echo "Cleaning up old Homebrew formulae ..."
brew cleanup

if [ -r "$HOME/.rcrc" ]; then
  fancy_echo "Updating dotfiles ..."
  rcup
fi

Write your customizations such that they can be run safely more than once. See the mac script for examples.

Laptop functions such as fancy_echo and gem_install_or_update can be used in your ~/.laptop.local.

See the wiki for more customization examples.

Contributing

Thank you, contributors!

By participating in this project, you agree to abide by the thoughtbot code of conduct.

Edit the mac file. Document in the README.md file. Update the CHANGELOG. Follow shell style guidelines by using ShellCheck and Syntastic.

brew install shellcheck

Testing your changes

Test your changes by running the script on a fresh install of macOS. You can use the free and open source emulator UTM.

Tip: Make a fresh virtual machine with the installation of macOS completed and your user created and first launch complete. Then duplicate that machine to test the script each time on a fresh install thats ready to go.

License

Copyright © 2011 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

laptop's People

Contributors

aljohri avatar christoomey avatar coisnepe avatar composerinteralia avatar cpytel avatar croaky avatar dayne avatar derekprior avatar djcp avatar edwardloveall avatar eebs avatar fagiani avatar fivetwentysix avatar gaqzi avatar geoffharcourt avatar github-actions[bot] avatar gohanlon avatar iwz avatar keith avatar kenyonj avatar kerrick avatar mike-burns avatar pbrisbin avatar purinkle avatar remy727 avatar seanpdoyle avatar sparksp avatar thcipriani avatar tysongach avatar zasman 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  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

laptop's Issues

Uninstalling?

There a quick way to uninstall all of this? Or is it pretty much manual?

Some errors when installing ruby gems.

Not sure if the issue is because gem update --system is failing

Updating rubygems-update
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
failed
Installing critical Ruby gems for Rails development ...
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --no-document
failed
Installing GitHub CLI client ...
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --no-document
failed

P.S: I manually ran the command and the gems installed fine.

P.P.S: Vanilla iMac, Mountain Lion.

What you think about tig?

brew install tig 
cd project && tig

Tig is a git repository browser that additionally can act as a pager for output from various git commands.

When browsing repositories, it uses the underlying git commands to present the user with various views, such as summarized revision log and showing the commit with the log message, diffstat, and the diff.

Using it as a pager, it will display input from stdin and colorize it.

blame-view

http://jonas.nitro.dk/tig/

Xcode is free for Mac OS X 10.7 Lion owners

Because of Apple’s conservative accounting practices, they charged $4.99 for folks running Snow Leopard who weren’t in the Mac or iOS developers program due to their interpretation of the Sarbanes-Oxley Act.

Anyone who buys Lion from the Mac App Store is entitled to a free copy of Xcode 4.

It would probably be a good idea to update the README so people aren’t confused.

Make script work on both bash and zsh

Without ZSH installed, script throws an error (~/.zshrc file doesn't exist).

We have these existing lines:

echo "
# recommended by brew doctor
export PATH='/usr/local/bin:$PATH'" >> ~/.zshrc
source ~/.zshrc

And:

echo "
# RVM
[[ -s '/Users/`whoami`/.rvm/scripts/rvm' ]] && source '/Users/`whoami`/.rvm/scripts/rvm'" >> ~/.zshrc
source ~/.zshrc

This script also begins with a shebang:

#!/usr/bin/env bash

Support Ubuntu 13.04

Now that it's out, test laptop to ensure support for 13.04 (raring ringtail).

Some error during installation

I had got a few errors during installation. It was a fresh install, in a new machine, with macox 10.8.3. Everything is fine until rubygems-update.

I quote from shell:

Updating to latest Rubygems version ...
Updating RubyGems
Updating rubygems-update
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

failed

Installing critical Ruby gems for Rails development ...
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --no-document

failed

Installing GitHub CLI client ...
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --no-document

failed

Does laptop require a clean install of os x Lion?

Im having a ton of errors on my install. Multiple .zshrc "command not found" errors. Multiple "failed to build gem native extension" errors, multiple RVM "error running ..." errors, "cant find header files for ruby at..." errors, RVM "there has been an error while running configure. Halting the installation"...

Wondering if you have experienced these and can steer me toward fixing them. Thanks for the script... I can post detailed error messages if needed...

Adding Mongodb option

I have forked this and I am planning on adding replacing PostgreSQL with Mongodb. Would there be a way to add this as an option to laptop? Perhaps a flag to use Mongodb instead of PostgreSQL?

Just curious, if not I will just leave the forked copy with Mongodb.

Thanks,

Bob

Awkward language corrections?

@croaky This is pretty minor, over all, but I believe statements like:

Install The Silver Searcher (better than ack or grep) for searching the contents of files ...

would sound better thusly:

Installing The Silver Searcher (better than ack or grep) to search the contents of files ...

but before I churn the hell out of everything I wanted to run it by you.

I mean, the script is installing something for you, and the thing it's installing is used to actively do something to something else.

Code review command

Works for projects using a ticket-number-in-branch convention.

#!/bin/sh

code-review()
{
  branch=`git branch -r | ack $1 | sed 's/.*\///'`
  git checkout $branch
}

Recommend Command Line Tools for XCode

We currently recommend in the script that people install GCC via GCC installer. However, some people might also have XCode installed. I found this note in the Ruby 1.9.3 release notes:

You have to configure ruby with '--with-gcc=gcc-4.2' if you're using
Xcode 4.1, or, if you're using Xcode 4.2, you have to configure ruby
with '--with-gcc=clang'

Should we be taking any kind of action here?

RVM doesn't install properly

Ran this script on a new build Mac Pro, running Lion OSX 10.7.4 and it appeared to have problems installing the gems. I had to reinstall RVM using code from the RVM site, then reload it so I was running Ruby version 1.9.3, then install gems manually.

Just thought it was worth mentioning :)

How about other mac's?

Content refers to laptop but can instructions be used on Mac mini, iMac, Mac Pro also?

Drop support of Ubuntu?

None of us actually run Ubuntu. It was put there originally for the HBS workshop.

Dropping support would allow us to do some more Mac-specific things like:

env ARCHFLAGS="-arch x86_64" gem install pg

Install vanilla gcc-4.2

If you use the newest Xcode Command Line Tools, Apple's vanilla gcc-4.2 is no longer installed. This is a problem if you still intend to compile/use earlier versions of Ruby. (I think a number of earlier Rubies have problems building with clang or llvm-gcc as well as a number of other things you may end up wanting.)

There are currently two ways to get gcc-4.2 that I know of:

Using Homebrew is simpler, but it places gcc-4.2 in /usr/local/bin. This is not optimal since some naive build-scripts hardcode an expectation of /usr/bin/gcc-4.2. (This came up yesterday in IRC #machomebrew.) Anyhow, for what it's worth, I used the second method, and it's clean sailing after that. You can default to clang or llvm-gcc, but run select builds with CC=/usr/bin/gcc-4.2 as needed.

Git ?

I'm wondering why this script neither requires git nor does it install git.

final step requires sudo for install of bundler, rails, heroku, tap and pg

I bought a new Mac Air on 10/2/2011
These instructions are very helpful.
An issue that I found is that the last step, running the script to install bundler, rails, heroku, tap and pg fails with permission issues.
So I am running the steps to install the components manually with sudo

Installing Bundler for managing Ruby libraries ...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Installing Rails to write and run web applications ...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Installing the Heroku gem to interact with the http://heroku.com API ...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Installing the Taps gem to push and pull SQL databases between development, staging, and production environments ...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Installing the pg gem to talk to Postgres databases ...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

Xcode is a prerequisite

I bought a new Mac Air on 10/2/2011
These instructions were really helpful.
An issue that I found is that before running the homebrew steps I had to install XCode first.
It was not installed by default.

Foreman twice

It looks like you install the foreman gem, as well as the Heroku Toolbelt.

The Toobelt includes Foreman. I think installing the gem in addition to Toolbelt may cause future problems. For example, the Toolbelt is auto-updating, and the gem isn't - so you might run into weird problems with an out-of-sync foreman vs Heroku command-line tool.

Upgrade to Ruby 2.0.0-p0

After we've evaluated Ruby 2.0.0-p0 on some projects in production, upgrade it here.

While we're at it, use --no-document flag consistently.

Install Jump

WRONG: i just want suggest Jump. I can't live without it :)

update
RIGHT: The right plugin is this AutoJump and for me is very useful :)

Run Postgres if not running

The laptop script currently installs, but does not run or set a plist file for Postgres. For the Mac script, we should be able to grab the lines from brew info postgres. Not sure what to use for the if statement.

Move linux support to use a custom apt repo

This would make the setup process for debian-derivative linux support stupid easy:

  1. Add the apt repo, accept the signing key.
  2. "aptitude install thoughtbot-rails-environment" (or whatever) which'd be a meta-package that depends on everything we install,
  3. run "thoughtbot-rails-setup" post-install to do the user-level scripted setup - install rbenv, set up zsh, etc.

The apt repo could live on heroku, no prob.

One drawback - what the setup script actually does will be less transparent, and this may be a problem if we assume that copy-and-pasteablilty for the laptop script is important.

permission denied

I used that manually:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
brew update

and got the error

error: unable to unlink old '.gitignore' (Permission denied)
 error: unable to unlink old 'README.md' (Permission denied)
fatal: Could not reset index file to revision 'FETCH_HEAD'.
rm: .git: Permission denied
Error: Failure while executing: rm -rf .git

Skipping if installed

I was just passing through this repository and it seemed like a good one. However, I was thinking it would be nice if a feature that checks if a particular software is already installed before installing it is added.

What do you guys think?

Mis-configured RVM?

I used the GCC standalone installer, then ran the script as shown.

I wind up with a confused location of gems:

WHICH RUBY

/Users/alexmcpherson/.rvm/gems/ruby-1.9.2-p290/bin/rails

RAILS -V

/Users/alexmcpherson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in to_specs': Could not find rails (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError) from /Users/alexmcpherson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:into_spec'
from /Users/alexmcpherson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in gem' from /Users/alexmcpherson/.rvm/gems/ruby-1.9.2-p290/bin/rails:18:in

'

Any thoughts why it thinks the gem would be in the /lib directory?

Otherwise smooth install, thanks for any hints.

Set up vundle

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

/usr/bin/ruby

I think there's a better way to access Ruby than /usr/bin/ruby. There's a way to reference a pointer to the default PATH'd Ruby instead of the actual executable.

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.