Skip to content

Instantly share code, notes, and snippets.

@joaopfsilva
Last active March 3, 2023 08:08
Show Gist options
  • Save joaopfsilva/3cfeeb31258d809372fbfec2b808393d to your computer and use it in GitHub Desktop.
Save joaopfsilva/3cfeeb31258d809372fbfec2b808393d to your computer and use it in GitHub Desktop.
Issues on Mojave
# Make sure openssl is installed on Mac via Homebrew.
# use ssh-agent to prevent inserting always the passphrase.
https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
brew install openssl
# MySQL installation
# ISSUE: mysql8 (default) has a different default authentication
# Install openssl and add to zshrc
brew install openssl
# add ssh key to remote server
cat ~/.ssh/id_rsa.pub | ssh username@server.address.com 'cat >> ~/.ssh/authorized_keys'
# Problems to run rails -> eventmachine
gem uninstall eventmachine # say Y always
gem install eventmachine
# Install mysql2 gem.
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
# path
/usr/local/etc/my.cnf
#disable new mysql8 auth
default_authentication_plugin=mysql_native_password
# force turning off connection to mysql 8
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# CAPISTRANO - error when deploying - ssh key
ssh-add ~/.ssh/id_rsa
# to check -> ssh-add -l
# Install rbenv-vars
brew install rbenv-vars
# ElasticSearch
# CONFIGURATION
Product.searchkick_index.delete # delete current index
Product.reindex # wait until it starts reindex all products and then `ctrl + c`
# reindex the products you want
# ISSUE: fielddata
# products_development -> change to index name
curl -X PUT http://localhost:9200/products_development -H 'Content-Type: application/json' -d '{
"mappings": {
"type": {
"properties": {
"brand": {
"type": "text",
"fielddata": true
}
}
}
}
}'
#upgrade NODE
https://github.com/nodesource/distributions/blob/master/README.md#deb
#update yarn
sudo apt upgrade yarn
# POSTGRESQL error bad connection
postgres -D /usr/local/var/postgres
kill -9 PID
#Elastic Search
## see data in index https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html
http://localhost:9200/products_development/_mapping/field/*
## ES - fielddata=true
PUT http://localhost:9200/products_development/_mapping/product
{
"product": {
"properties": {
"brand": {
"type": "text",
"fielddata": true
},
}
}
}
## ES - create/delete index
Product.search_index.create|delete
#slack notifications not working on slack
# Require dotenv
require "dotenv"
# Make sure dotenv data is loaded into the environment
Dotenv.load
#node-sass not compatible with node v16
node-sass is not yet compatible with node v16
A wise thing to do is to downgrade node (e.g. to version 14) until node-sass is compatible with v16. To downgrade node using nvm, simply run:
nvm install 14
Set version 14 globally (so each new terminal windows defaults to node version 14) by running:
nvm alias default 14
Now you have node 14 installed and set as default! ..now you just need to make your app use v14.
How to make your rails app use node 14
Install node 14 (see above). Open terminal and head to your app's root directory, then:
Stop your rails server if it's running
Open a fresh new terminal window (so that node --version returns 14.x (not 16)
Run spring stop
Delete yarn.lock
Remove existing node modules with rm -rf node_modules
Check that node --version returns 14. If it doesn't run nvm install 14 again.
Now reinstall modules with yarn install (if you don't have yarn for node 14, install it with npm install --global yarn)
It should succeed!
Restart your rails server, and it will work!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment